@@ -150,12 +150,23 @@ static LineSenderBuilder builder(CharSequence configurationString) {
150150 * @return Builder object to create a new Sender instance.
151151 */
152152 static LineSenderBuilder builder (Transport transport ) {
153- int protocol = switch (transport ) {
154- case HTTP -> LineSenderBuilder .PROTOCOL_HTTP ;
155- case TCP -> LineSenderBuilder .PROTOCOL_TCP ;
156- case UDP -> LineSenderBuilder .PROTOCOL_UDP ;
157- case WEBSOCKET -> LineSenderBuilder .PROTOCOL_WEBSOCKET ;
158- };
153+ int protocol ;
154+ switch (transport ) {
155+ case HTTP :
156+ protocol = LineSenderBuilder .PROTOCOL_HTTP ;
157+ break ;
158+ case TCP :
159+ protocol = LineSenderBuilder .PROTOCOL_TCP ;
160+ break ;
161+ case UDP :
162+ protocol = LineSenderBuilder .PROTOCOL_UDP ;
163+ break ;
164+ case WEBSOCKET :
165+ protocol = LineSenderBuilder .PROTOCOL_WEBSOCKET ;
166+ break ;
167+ default :
168+ throw new IllegalArgumentException ("unknown transport: " + transport );
169+ }
159170 return new LineSenderBuilder (protocol );
160171 }
161172
@@ -927,13 +938,19 @@ public Sender build() {
927938 channel = tlsChannel ;
928939 }
929940 try {
930- sender = switch (protocolVersion ) {
931- case PROTOCOL_VERSION_V1 -> new LineTcpSenderV1 (channel , bufferCapacity , maxNameLength );
932- case PROTOCOL_VERSION_V2 -> new LineTcpSenderV2 (channel , bufferCapacity , maxNameLength );
933- case PROTOCOL_VERSION_V3 -> new LineTcpSenderV3 (channel , bufferCapacity , maxNameLength );
934- default ->
935- throw new LineSenderException ("unknown protocol version [version=" ).put (protocolVersion ).put ("]" );
936- };
941+ switch (protocolVersion ) {
942+ case PROTOCOL_VERSION_V1 :
943+ sender = new LineTcpSenderV1 (channel , bufferCapacity , maxNameLength );
944+ break ;
945+ case PROTOCOL_VERSION_V2 :
946+ sender = new LineTcpSenderV2 (channel , bufferCapacity , maxNameLength );
947+ break ;
948+ case PROTOCOL_VERSION_V3 :
949+ sender = new LineTcpSenderV3 (channel , bufferCapacity , maxNameLength );
950+ break ;
951+ default :
952+ throw new LineSenderException ("unknown protocol version [version=" ).put (protocolVersion ).put ("]" );
953+ }
937954 } catch (Throwable t ) {
938955 channel .close ();
939956 throw rethrow (t );
@@ -1541,14 +1558,24 @@ private LineSenderBuilder fromConfig(CharSequence configurationString) {
15411558 throw new LineSenderException ("invalid configuration string: " ).put (sink );
15421559 }
15431560 if (protocol != PARAMETER_NOT_SET_EXPLICITLY ) {
1561+ String protocolName ;
1562+ switch (protocol ) {
1563+ case PROTOCOL_HTTP :
1564+ protocolName = "http" ;
1565+ break ;
1566+ case PROTOCOL_UDP :
1567+ protocolName = "udp" ;
1568+ break ;
1569+ case PROTOCOL_WEBSOCKET :
1570+ protocolName = "websocket" ;
1571+ break ;
1572+ default :
1573+ protocolName = "tcp" ;
1574+ break ;
1575+ }
15441576 throw new LineSenderException ("protocol was already configured " )
15451577 .put ("[protocol=" )
1546- .put (switch (protocol ) {
1547- case PROTOCOL_HTTP -> "http" ;
1548- case PROTOCOL_UDP -> "udp" ;
1549- case PROTOCOL_WEBSOCKET -> "websocket" ;
1550- default -> "tcp" ;
1551- }).put ("]" );
1578+ .put (protocolName ).put ("]" );
15521579 }
15531580 if (Chars .equals ("http" , sink )) {
15541581 if (tlsEnabled ) {
0 commit comments