Remove unnecessary toString calls (#11550)
Motivation: We should get rid of the unnecessary toString calls because they're redundant in nature. Modification: Removed unnecessary toString calls. Result: Better code
This commit is contained in:
parent
01b42c568d
commit
6e387e2f5d
@ -286,14 +286,14 @@ public class HttpResponseEncoderTest {
|
|||||||
|
|
||||||
ByteBuf buffer = channel.readOutbound();
|
ByteBuf buffer = channel.readOutbound();
|
||||||
StringBuilder responseText = new StringBuilder();
|
StringBuilder responseText = new StringBuilder();
|
||||||
responseText.append(HttpVersion.HTTP_1_1.toString()).append(' ').append(status.toString()).append("\r\n");
|
responseText.append(HttpVersion.HTTP_1_1).append(' ').append(status.toString()).append("\r\n");
|
||||||
if (!headerStripped && headerName != null) {
|
if (!headerStripped && headerName != null) {
|
||||||
responseText.append(headerName).append(": ");
|
responseText.append(headerName).append(": ");
|
||||||
|
|
||||||
if (HttpHeaderNames.CONTENT_LENGTH.contentEquals(headerName)) {
|
if (HttpHeaderNames.CONTENT_LENGTH.contentEquals(headerName)) {
|
||||||
responseText.append('0');
|
responseText.append('0');
|
||||||
} else {
|
} else {
|
||||||
responseText.append(HttpHeaderValues.CHUNKED.toString());
|
responseText.append(HttpHeaderValues.CHUNKED);
|
||||||
}
|
}
|
||||||
responseText.append("\r\n");
|
responseText.append("\r\n");
|
||||||
}
|
}
|
||||||
@ -383,8 +383,8 @@ public class HttpResponseEncoderTest {
|
|||||||
assertTrue(channel.writeOutbound(LastHttpContent.EMPTY_LAST_CONTENT));
|
assertTrue(channel.writeOutbound(LastHttpContent.EMPTY_LAST_CONTENT));
|
||||||
|
|
||||||
StringBuilder responseText = new StringBuilder();
|
StringBuilder responseText = new StringBuilder();
|
||||||
responseText.append(HttpVersion.HTTP_1_1.toString()).append(' ')
|
responseText.append(HttpVersion.HTTP_1_1).append(' ')
|
||||||
.append(HttpResponseStatus.RESET_CONTENT.toString()).append("\r\n");
|
.append(HttpResponseStatus.RESET_CONTENT).append("\r\n");
|
||||||
responseText.append(HttpHeaderNames.CONTENT_LENGTH).append(": 0\r\n");
|
responseText.append(HttpHeaderNames.CONTENT_LENGTH).append(": 0\r\n");
|
||||||
responseText.append("\r\n");
|
responseText.append("\r\n");
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class Http2StreamFrameToHttpObjectCodec extends MessageToMessageCodec<Htt
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new EncoderException(
|
throw new EncoderException(
|
||||||
HttpResponseStatus.CONTINUE.toString() + " must be a FullHttpResponse");
|
HttpResponseStatus.CONTINUE + " must be a FullHttpResponse");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,15 +182,15 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
|||||||
case SUBSCRIBE:
|
case SUBSCRIBE:
|
||||||
case UNSUBSCRIBE:
|
case UNSUBSCRIBE:
|
||||||
if (dupFlag) {
|
if (dupFlag) {
|
||||||
throw new DecoderException("Illegal BIT 3 in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal BIT 3 in fixed header of " + messageType
|
||||||
+ " message, must be 0, found 1");
|
+ " message, must be 0, found 1");
|
||||||
}
|
}
|
||||||
if (qosLevel != 1) {
|
if (qosLevel != 1) {
|
||||||
throw new DecoderException("Illegal QOS Level in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal QOS Level in fixed header of " + messageType
|
||||||
+ " message, must be 1, found " + qosLevel);
|
+ " message, must be 1, found " + qosLevel);
|
||||||
}
|
}
|
||||||
if (retain) {
|
if (retain) {
|
||||||
throw new DecoderException("Illegal BIT 0 in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal BIT 0 in fixed header of " + messageType
|
||||||
+ " message, must be 0, found 1");
|
+ " message, must be 0, found 1");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -207,15 +207,15 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
|||||||
case SUBACK:
|
case SUBACK:
|
||||||
case UNSUBACK:
|
case UNSUBACK:
|
||||||
if (dupFlag) {
|
if (dupFlag) {
|
||||||
throw new DecoderException("Illegal BIT 3 in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal BIT 3 in fixed header of " + messageType
|
||||||
+ " message, must be 0, found 1");
|
+ " message, must be 0, found 1");
|
||||||
}
|
}
|
||||||
if (qosLevel != 0) {
|
if (qosLevel != 0) {
|
||||||
throw new DecoderException("Illegal BIT 2 or 1 in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal BIT 2 or 1 in fixed header of " + messageType
|
||||||
+ " message, must be 0, found " + qosLevel);
|
+ " message, must be 0, found " + qosLevel);
|
||||||
}
|
}
|
||||||
if (retain) {
|
if (retain) {
|
||||||
throw new DecoderException("Illegal BIT 0 in fixed header of " + messageType.toString()
|
throw new DecoderException("Illegal BIT 0 in fixed header of " + messageType
|
||||||
+ " message, must be 0, found 1");
|
+ " message, must be 0, found 1");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -342,9 +342,9 @@ public class StompSubframeDecoder extends ReplayingDecoder<State> {
|
|||||||
headers.add(name, value.toString());
|
headers.add(name, value.toString());
|
||||||
} else if (validateHeaders) {
|
} else if (validateHeaders) {
|
||||||
if (StringUtil.isNullOrEmpty(name)) {
|
if (StringUtil.isNullOrEmpty(name)) {
|
||||||
throw new IllegalArgumentException("received an invalid header line '" + value.toString() + '\'');
|
throw new IllegalArgumentException("received an invalid header line '" + value + '\'');
|
||||||
}
|
}
|
||||||
String line = name + ':' + value.toString();
|
String line = name + ':' + value;
|
||||||
throw new IllegalArgumentException("a header value or name contains a prohibited character ':'"
|
throw new IllegalArgumentException("a header value or name contains a prohibited character ':'"
|
||||||
+ ", " + line);
|
+ ", " + line);
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
|
|
||||||
public class ResolveAddressHandlerTest {
|
public class ResolveAddressHandlerTest {
|
||||||
|
|
||||||
private static final LocalAddress UNRESOLVED = new LocalAddress("unresolved-" + UUID.randomUUID().toString());
|
private static final LocalAddress UNRESOLVED = new LocalAddress("unresolved-" + UUID.randomUUID());
|
||||||
private static final LocalAddress RESOLVED = new LocalAddress("resolved-" + UUID.randomUUID().toString());
|
private static final LocalAddress RESOLVED = new LocalAddress("resolved-" + UUID.randomUUID());
|
||||||
private static final Exception ERROR = new UnknownHostException();
|
private static final Exception ERROR = new UnknownHostException();
|
||||||
|
|
||||||
private static EventLoopGroup group;
|
private static EventLoopGroup group;
|
||||||
|
Loading…
Reference in New Issue
Block a user