diff --git a/buffer/src/main/java/io/netty/buffer/DefaultCompositeByteBuf.java b/buffer/src/main/java/io/netty/buffer/DefaultCompositeByteBuf.java index 341139bf29..8c79994b0e 100644 --- a/buffer/src/main/java/io/netty/buffer/DefaultCompositeByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/DefaultCompositeByteBuf.java @@ -1217,7 +1217,7 @@ public class DefaultCompositeByteBuf extends AbstractByteBuf implements Composit public String toString() { String result = super.toString(); result = result.substring(0, result.length() - 1); - return result + ", components=" + components.size() + ")"; + return result + ", components=" + components.size() + ')'; } private static final class Component { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java index 769d03c190..76756b2812 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java @@ -1245,7 +1245,7 @@ public class HttpHeaders { @Override public String toString() { - return key + "=" + value; + return key + '=' + value; } } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java index 526a97112e..f732770dbc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java @@ -163,7 +163,7 @@ public class QueryStringDecoder { hasPath = false; } // Also take care of cut of things like "http://localhost" - String newUri = rawPath + "?" + uri.getRawQuery(); + String newUri = rawPath + '?' + uri.getRawQuery(); // http://en.wikipedia.org/wiki/Query_string this.uri = newUri.replace(';', '&'); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java index 14ba09fc6e..71d8acdb96 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java @@ -100,14 +100,14 @@ public class QueryStringEncoder { if (params.isEmpty()) { return uri; } else { - StringBuilder sb = new StringBuilder(uri).append("?"); + StringBuilder sb = new StringBuilder(uri).append('?'); for (int i = 0; i < params.size(); i++) { Param param = params.get(i); sb.append(encodeComponent(param.name, charset)); - sb.append("="); + sb.append('='); sb.append(encodeComponent(param.value, charset)); if (i != params.size() - 1) { - sb.append("&"); + sb.append('&'); } } return sb.toString(); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java index 47b98a4a87..e7f3443cd2 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java @@ -15,7 +15,6 @@ */ package io.netty.handler.codec.http.multipart; -import static io.netty.buffer.Unpooled.*; import io.netty.buffer.ByteBuf; import io.netty.handler.codec.http.HttpConstants; @@ -28,6 +27,8 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; +import static io.netty.buffer.Unpooled.*; + /** * Abstract Disk HttpData implementation */ @@ -76,7 +77,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData { String newpostfix = null; String diskFilename = getDiskFilename(); if (diskFilename != null) { - newpostfix = "_" + diskFilename; + newpostfix = '_' + diskFilename; } else { newpostfix = getPostfix(); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskAttribute.java index 76d313ee5e..750d241ede 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskAttribute.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskAttribute.java @@ -15,10 +15,11 @@ */ package io.netty.handler.codec.http.multipart; -import java.io.IOException; - import io.netty.buffer.ByteBuf; import io.netty.handler.codec.http.HttpConstants; + +import java.io.IOException; + import static io.netty.buffer.Unpooled.*; /** @@ -115,7 +116,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute { @Override public String toString() { try { - return getName() + "=" + getValue(); + return getName() + '=' + getValue(); } catch (IOException e) { return getName() + "=IoException"; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskFileUpload.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskFileUpload.java index 26c67295b0..6a55b58908 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskFileUpload.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DiskFileUpload.java @@ -15,11 +15,11 @@ */ package io.netty.handler.codec.http.multipart; +import io.netty.handler.codec.http.HttpHeaders; + import java.io.File; import java.nio.charset.Charset; -import io.netty.handler.codec.http.HttpHeaders; - /** * Disk FileUpload implementation that stores file into real files */ @@ -126,7 +126,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload { HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() + "\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" + HttpHeaders.Names.CONTENT_TYPE + ": " + contentType + - (charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") + + (charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") + HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" + "Completed: " + isCompleted() + "\r\nIsInMemory: " + isInMemory() + "\r\nRealFile: " + diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java index 22e111cc31..f1e8adb3a9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java @@ -706,7 +706,7 @@ public class HttpPostRequestDecoder { } catch (UnsupportedEncodingException e) { throw new ErrorDataDecoderException(charset.toString(), e); } catch (IllegalArgumentException e) { - throw new ErrorDataDecoderException("Bad string: '" + s + "'", e); + throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java index 5511640106..b379f599ff 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java @@ -454,7 +454,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput { Charset localcharset = attribute.getCharset(); if (localcharset != null) { // Content-Type: charset=charset - internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + HttpHeaders.Values.CHARSET + "=" + internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + HttpHeaders.Values.CHARSET + '=' + localcharset + "\r\n"); } // CRLF between body header and data @@ -524,7 +524,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput { + "; " + HttpPostBodyUtil.NAME + "=\"" + encodeAttribute(fileUpload.getName(), charset) + "\"\r\n"; replacement += HttpHeaders.Names.CONTENT_TYPE + ": " + HttpPostBodyUtil.MULTIPART_MIXED + "; " - + HttpHeaders.Values.BOUNDARY + "=" + multipartMixedBoundary + "\r\n\r\n"; + + HttpHeaders.Values.BOUNDARY + '=' + multipartMixedBoundary + "\r\n\r\n"; replacement += "--" + multipartMixedBoundary + "\r\n"; replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " + HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" + encodeAttribute(fileUpload.getFilename(), charset) @@ -577,7 +577,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput { internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING + ": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() + "\r\n\r\n"); } else if (fileUpload.getCharset() != null) { - internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" + fileUpload.getCharset() + "\r\n\r\n"); + internal.addValue("; " + HttpHeaders.Values.CHARSET + '=' + fileUpload.getCharset() + "\r\n\r\n"); } else { internal.addValue("\r\n\r\n"); } @@ -637,7 +637,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput { } } if (isMultipart) { - String value = HttpHeaders.Values.MULTIPART_FORM_DATA + "; " + HttpHeaders.Values.BOUNDARY + "=" + String value = HttpHeaders.Values.MULTIPART_FORM_DATA + "; " + HttpHeaders.Values.BOUNDARY + '=' + multipartDataBoundary; request.addHeader(HttpHeaders.Names.CONTENT_TYPE, value); } else { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryAttribute.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryAttribute.java index 045acbab9e..d9da52ad67 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryAttribute.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryAttribute.java @@ -103,7 +103,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute @Override public String toString() { - return getName() + "=" + getValue(); + return getName() + '=' + getValue(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryFileUpload.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryFileUpload.java index 0dc3074304..3e4f632e2f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryFileUpload.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/MemoryFileUpload.java @@ -120,7 +120,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() + "\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" + HttpHeaders.Names.CONTENT_TYPE + ": " + contentType + - (charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") + + (charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") + HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" + "Completed: " + isCompleted() + "\r\nIsInMemory: " + isInMemory(); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java index b9e9eac6dc..32de9c1b59 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java @@ -134,7 +134,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { URI wsURL = getWebSocketUrl(); String path = wsURL.getPath(); if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) { - path = wsURL.getPath() + "?" + wsURL.getQuery(); + path = wsURL.getPath() + '?' + wsURL.getQuery(); } // Format request @@ -148,14 +148,14 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { if (wsPort != 80 && wsPort != 443) { // if the port is not standard (80/443) its needed to add the port to the header. // See http://tools.ietf.org/html/rfc6454#section-6.2 - originValue = originValue + ":" + wsPort; + originValue = originValue + ':' + wsPort; } request.addHeader(Names.ORIGIN, originValue); request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1); request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2); String expectedSubprotocol = getExpectedSubprotocol(); - if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) { + if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) { request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } @@ -269,7 +269,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { int split = WebSocketUtil.randomNumber(1, key.length() - 1); String part1 = key.substring(0, split); String part2 = key.substring(split); - key = part1 + " " + part2; + key = part1 + ' ' + part2; } return key; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java index 305aaf7a2d..3c65195173 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java @@ -102,7 +102,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { URI wsURL = getWebSocketUrl(); String path = wsURL.getPath(); if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) { - path = wsURL.getPath() + "?" + wsURL.getQuery(); + path = wsURL.getPath() + '?' + wsURL.getQuery(); } // Get 16 bit nonce and base 64 encode it @@ -130,12 +130,12 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { if (wsPort != 80 && wsPort != 443) { // if the port is not standard (80/443) its needed to add the port to the header. // See http://tools.ietf.org/html/rfc6454#section-6.2 - originValue = originValue + ":" + wsPort; + originValue = originValue + ':' + wsPort; } request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue); String expectedSubprotocol = getExpectedSubprotocol(); - if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) { + if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) { request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java index 15e131437d..ea61f0e2a5 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java @@ -102,7 +102,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { URI wsURL = getWebSocketUrl(); String path = wsURL.getPath(); if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) { - path = wsURL.getPath() + "?" + wsURL.getQuery(); + path = wsURL.getPath() + '?' + wsURL.getQuery(); } // Get 16 bit nonce and base 64 encode it @@ -130,12 +130,12 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { if (wsPort != 80 && wsPort != 443) { // if the port is not standard (80/443) its needed to add the port to the header. // See http://tools.ietf.org/html/rfc6454#section-6.2 - originValue = originValue + ":" + wsPort; + originValue = originValue + ':' + wsPort; } request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue); String expectedSubprotocol = getExpectedSubprotocol(); - if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) { + if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) { request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java index 17b1b5000e..fd9022e6c1 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java @@ -134,7 +134,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame { Setting setting = e.getValue(); buf.append("--> "); buf.append(e.getKey().toString()); - buf.append(":"); + buf.append(':'); buf.append(setting.getValue()); buf.append(" (persist value: "); buf.append(setting.isPersist()); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaders.java index 336df21017..bcea411c95 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaders.java @@ -760,7 +760,7 @@ public class SpdyHeaders { @Override public String toString() { - return key + "=" + value; + return key + '=' + value; } } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java index b3aa367753..489560b45a 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java @@ -65,7 +65,7 @@ public class HttpServerCodecTest { private static ByteBuf prepareDataChunk(int size) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < size; ++i) { - sb.append("a"); + sb.append('a'); } return Unpooled.copiedBuffer(sb.toString(), CharsetUtil.UTF_8); } diff --git a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java index 6347ba8d98..e3111f9e7a 100644 --- a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java @@ -429,7 +429,7 @@ public abstract class ReplayingDecoder extends ByteToMessageDecoder { throw new IllegalStateException( "decode() method must consume at least one byte " + "if it returned a decoded message (caused by: " + - getClass() + ")"); + getClass() + ')'); } // A successful decode diff --git a/codec/src/main/java/io/netty/handler/codec/compression/ZlibUtil.java b/codec/src/main/java/io/netty/handler/codec/compression/ZlibUtil.java index 0eaebd356c..bcb9af3c8a 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/ZlibUtil.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/ZlibUtil.java @@ -28,7 +28,7 @@ final class ZlibUtil { } static CompressionException exception(ZStream z, String message, int resultCode) { - return new CompressionException(message + " (" + resultCode + ")" + + return new CompressionException(message + " (" + resultCode + ')' + (z.msg != null? ": " + z.msg : "")); } diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java index 196eeec75c..e3a47d2556 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingDecoderTest.java @@ -15,26 +15,26 @@ */ package io.netty.handler.codec.marshalling; -import static org.junit.Assert.*; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; import io.netty.channel.embedded.EmbeddedByteChannel; import io.netty.handler.codec.CodecException; import io.netty.handler.codec.TooLongFrameException; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - import junit.framework.Assert; - import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.MarshallerFactory; import org.jboss.marshalling.Marshalling; import org.jboss.marshalling.MarshallingConfiguration; import org.junit.Test; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import static org.junit.Assert.*; + public abstract class AbstractCompatibleMarshallingDecoderTest { + @SuppressWarnings("RedundantStringConstructorCall") private final String testObject = new String("test"); @Test diff --git a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java index 98675b345f..03b2579c5f 100644 --- a/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/marshalling/AbstractCompatibleMarshallingEncoderTest.java @@ -18,21 +18,20 @@ package io.netty.handler.codec.marshalling; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.embedded.EmbeddedByteChannel; - -import java.io.IOException; - import junit.framework.Assert; - import org.jboss.marshalling.MarshallerFactory; import org.jboss.marshalling.Marshalling; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.Unmarshaller; import org.junit.Test; +import java.io.IOException; + public abstract class AbstractCompatibleMarshallingEncoderTest { @Test public void testMarshalling() throws IOException, ClassNotFoundException { + @SuppressWarnings("RedundantStringConstructorCall") String testObject = new String("test"); final MarshallerFactory marshallerFactory = createMarshallerFactory(); diff --git a/common/src/main/java/io/netty/logging/OsgiLogger.java b/common/src/main/java/io/netty/logging/OsgiLogger.java index ddf1c2b282..0320268a4d 100644 --- a/common/src/main/java/io/netty/logging/OsgiLogger.java +++ b/common/src/main/java/io/netty/logging/OsgiLogger.java @@ -31,7 +31,7 @@ class OsgiLogger extends AbstractInternalLogger { this.parent = parent; this.name = name; this.fallback = fallback; - prefix = "[" + name + "] "; + prefix = '[' + name + "] "; } @Override diff --git a/common/src/main/java/io/netty/monitor/MonitorName.java b/common/src/main/java/io/netty/monitor/MonitorName.java index 983dd5106b..f73ce8f7f8 100644 --- a/common/src/main/java/io/netty/monitor/MonitorName.java +++ b/common/src/main/java/io/netty/monitor/MonitorName.java @@ -251,7 +251,7 @@ public final class MonitorName { */ @Override public String toString() { - return instance != null ? "Monitor(" + group + "/" + type + "/" + name + "/" + instance + ")" : "Monitor(" - + group + "/" + type + "/" + name + ")"; + return instance != null ? "Monitor(" + group + '/' + type + '/' + name + '/' + instance + ')' : "Monitor(" + + group + '/' + type + '/' + name + ')'; } } diff --git a/common/src/main/java/io/netty/monitor/spi/MonitorProvider.java b/common/src/main/java/io/netty/monitor/spi/MonitorProvider.java index 2b205fc2e3..81164e1b6a 100644 --- a/common/src/main/java/io/netty/monitor/spi/MonitorProvider.java +++ b/common/src/main/java/io/netty/monitor/spi/MonitorProvider.java @@ -107,6 +107,6 @@ public final class MonitorProvider implements Serializable, Comparable> headers = request.getHeaders(); for (Entry entry : headers) { - responseContent.append("HEADER: " + entry.getKey() + "=" + entry.getValue() + "\r\n"); + responseContent.append("HEADER: " + entry.getKey() + '=' + entry.getValue() + "\r\n"); } responseContent.append("\r\n\r\n"); @@ -142,7 +142,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter Map> uriAttributes = decoderQuery.getParameters(); for (Entry> attr: uriAttributes.entrySet()) { for (String attrVal: attr.getValue()) { - responseContent.append("URI: " + attr.getKey() + "=" + attrVal + "\r\n"); + responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n"); } } responseContent.append("\r\n\r\n"); @@ -189,7 +189,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter ctx.channel().close(); return; } - responseContent.append("o"); + responseContent.append('o'); // example of reading chunk by chunk (minimize memory usage due to // Factory) readHttpDataChunkByChunk(ctx.channel()); diff --git a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClientHandler.java b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClientHandler.java index b852d3941f..8902029a6c 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClientHandler.java +++ b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClientHandler.java @@ -90,7 +90,7 @@ public class WebSocketClientHandler extends ChannelInboundMessageHandlerAdapter< if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; throw new Exception("Unexpected HttpResponse (status=" + response.getStatus() + ", content=" - + response.getContent().toString(CharsetUtil.UTF_8) + ")"); + + response.getContent().toString(CharsetUtil.UTF_8) + ')'); } WebSocketFrame frame = (WebSocketFrame) msg; diff --git a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerIndexPage.java b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerIndexPage.java index 13958442ec..8431af67a9 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerIndexPage.java +++ b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerIndexPage.java @@ -34,7 +34,7 @@ public final class WebSocketServerIndexPage { "var socket;" + NEWLINE + "if (!window.WebSocket) {" + NEWLINE + " window.WebSocket = window.MozWebSocket;" + NEWLINE + - "}" + NEWLINE + + '}' + NEWLINE + "if (window.WebSocket) {" + NEWLINE + " socket = new WebSocket(\"" + webSocketLocation + "\");" + NEWLINE + " socket.onmessage = function(event) {" + NEWLINE + @@ -51,7 +51,7 @@ public final class WebSocketServerIndexPage { " };" + NEWLINE + "} else {" + NEWLINE + " alert(\"Your browser does not support Web Socket.\");" + NEWLINE + - "}" + NEWLINE + + '}' + NEWLINE + NEWLINE + "function send(message) {" + NEWLINE + " if (!window.WebSocket) { return; }" + NEWLINE + @@ -60,7 +60,7 @@ public final class WebSocketServerIndexPage { " } else {" + NEWLINE + " alert(\"The socket is not open.\");" + NEWLINE + " }" + NEWLINE + - "}" + NEWLINE + + '}' + NEWLINE + "" + NEWLINE + "
" + NEWLINE + "" + diff --git a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java index 92aeaa7585..2cc0fc52de 100644 --- a/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java +++ b/example/src/main/java/io/netty/example/localtime/LocalTimeClient.java @@ -108,7 +108,7 @@ public class LocalTimeClient { List cities = new ArrayList(); for (int i = offset; i < args.length; i ++) { if (!CITY_PATTERN.matcher(args[i]).matches()) { - System.err.println("Syntax error: '" + args[i] + "'"); + System.err.println("Syntax error: '" + args[i] + '\''); printUsage(); return null; } diff --git a/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java b/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java index 4cf69426a5..d456342d88 100644 --- a/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java +++ b/example/src/main/java/io/netty/example/uptime/UptimeClientHandler.java @@ -77,7 +77,7 @@ public class UptimeClientHandler extends ChannelInboundByteHandlerAdapter { @Override public void channelUnregistered(final ChannelHandlerContext ctx) throws Exception { - println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + "s"); + println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's'); final EventLoop loop = ctx.channel().eventLoop(); loop.schedule(new Runnable() { diff --git a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerCounterMonitor.java b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerCounterMonitor.java index 7d14b99c8b..37b5efe2cc 100644 --- a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerCounterMonitor.java +++ b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerCounterMonitor.java @@ -84,6 +84,6 @@ class YammerCounterMonitor implements CounterMonitor { */ @Override public String toString() { - return "YammerCounterMonitor(delegate=" + delegate + ")"; + return "YammerCounterMonitor(delegate=" + delegate + ')'; } } diff --git a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerEventRateMonitor.java b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerEventRateMonitor.java index 95208074ca..e8aee470be 100644 --- a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerEventRateMonitor.java +++ b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerEventRateMonitor.java @@ -62,6 +62,6 @@ class YammerEventRateMonitor implements EventRateMonitor { */ @Override public String toString() { - return "YammerEventRateMonitor(delegate=" + delegate + ")"; + return "YammerEventRateMonitor(delegate=" + delegate + ')'; } } diff --git a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerMonitorRegistry.java b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerMonitorRegistry.java index 08ce4c61b2..558778efec 100644 --- a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerMonitorRegistry.java +++ b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerMonitorRegistry.java @@ -117,6 +117,6 @@ public final class YammerMonitorRegistry implements MonitorRegistry { */ @Override public String toString() { - return "YammerMonitorRegistry(delegate=" + delegate + ")"; + return "YammerMonitorRegistry(delegate=" + delegate + ')'; } } diff --git a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerValueDistributionMonitor.java b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerValueDistributionMonitor.java index 9219f39a61..7c8f01ab66 100644 --- a/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerValueDistributionMonitor.java +++ b/metrics-yammer/src/main/java/io/netty/monitor/yammer/YammerValueDistributionMonitor.java @@ -60,6 +60,6 @@ final class YammerValueDistributionMonitor implements ValueDistributionMonitor { */ @Override public String toString() { - return "YammerEventDistributionMonitor(delegate=" + delegate + ")"; + return "YammerEventDistributionMonitor(delegate=" + delegate + ')'; } } diff --git a/metrics-yammer/src/main/java/io/netty/monitor/yammer/spi/YammerMonitorRegistryFactory.java b/metrics-yammer/src/main/java/io/netty/monitor/yammer/spi/YammerMonitorRegistryFactory.java index 7bdabf091f..ac3e25b08a 100644 --- a/metrics-yammer/src/main/java/io/netty/monitor/yammer/spi/YammerMonitorRegistryFactory.java +++ b/metrics-yammer/src/main/java/io/netty/monitor/yammer/spi/YammerMonitorRegistryFactory.java @@ -71,6 +71,6 @@ public class YammerMonitorRegistryFactory implements MonitorRegistryFactory { */ @Override public String toString() { - return "YammerMonitorRegistryFactory(metricsRegistry=" + metricsRegistry + ")"; + return "YammerMonitorRegistryFactory(metricsRegistry=" + metricsRegistry + ')'; } } diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelFuture.java b/transport/src/main/java/io/netty/channel/DefaultChannelFuture.java index b8e8d388b3..ea6369ca0d 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelFuture.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelFuture.java @@ -15,7 +15,6 @@ */ package io.netty.channel; -import static java.util.concurrent.TimeUnit.*; import io.netty.channel.ChannelFlushFutureNotifier.FlushCheckpoint; import io.netty.logging.InternalLogger; import io.netty.logging.InternalLoggerFactory; @@ -28,6 +27,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import static java.util.concurrent.TimeUnit.*; + /** * The default {@link ChannelFuture} implementation. It is recommended to * use {@link Channels#future(Channel)} and {@link Channels#future(Channel, boolean)} @@ -492,7 +493,7 @@ public class DefaultChannelFuture extends FlushCheckpoint implements ChannelFutu if (logger.isWarnEnabled()) { logger.warn( "An exception was thrown by " + - ChannelFutureListener.class.getSimpleName() + ".", t); + ChannelFutureListener.class.getSimpleName() + '.', t); } } } @@ -534,7 +535,7 @@ public class DefaultChannelFuture extends FlushCheckpoint implements ChannelFutu if (logger.isWarnEnabled()) { logger.warn( "An exception was thrown by " + - ChannelFutureProgressListener.class.getSimpleName() + ".", t); + ChannelFutureProgressListener.class.getSimpleName() + '.', t); } } } diff --git a/transport/src/main/java/io/netty/channel/group/DefaultChannelGroupFuture.java b/transport/src/main/java/io/netty/channel/group/DefaultChannelGroupFuture.java index 8f0b1ab409..149e766868 100644 --- a/transport/src/main/java/io/netty/channel/group/DefaultChannelGroupFuture.java +++ b/transport/src/main/java/io/netty/channel/group/DefaultChannelGroupFuture.java @@ -370,7 +370,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture { if (logger.isWarnEnabled()) { logger.warn( "An exception was thrown by " + - ChannelFutureListener.class.getSimpleName() + ".", t); + ChannelFutureListener.class.getSimpleName() + '.', t); } } } diff --git a/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java b/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java index f1f9a1c2b5..73da9e6f26 100644 --- a/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java +++ b/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java @@ -15,7 +15,6 @@ */ package io.netty.channel.socket; -import static io.netty.channel.ChannelOption.*; import io.netty.channel.ChannelException; import io.netty.channel.ChannelOption; import io.netty.channel.DefaultChannelConfig; @@ -31,6 +30,8 @@ import java.net.NetworkInterface; import java.net.SocketException; import java.util.Map; +import static io.netty.channel.ChannelOption.*; + /** * The default {@link DatagramChannelConfig} implementation. */ @@ -151,7 +152,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig implement "A non-root user can't receive a broadcast packet if the socket " + "is not bound to a wildcard address; setting the SO_BROADCAST flag " + "anyway as requested on the socket which is bound to " + - socket.getLocalSocketAddress() + "."); + socket.getLocalSocketAddress() + '.'); } socket.setBroadcast(broadcast); diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java index 9e95313290..83dadcbdeb 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java @@ -111,7 +111,7 @@ public final class NioEventLoop extends SingleThreadEventLoop { } if ((interestOps & ~ch.validOps()) != 0) { throw new IllegalArgumentException( - "invalid interestOps: " + interestOps + "(validOps: " + ch.validOps() + ")"); + "invalid interestOps: " + interestOps + "(validOps: " + ch.validOps() + ')'); } if (task == null) { throw new NullPointerException("task"); diff --git a/transport/src/main/java/io/netty/channel/socket/nio/SelectorUtil.java b/transport/src/main/java/io/netty/channel/socket/nio/SelectorUtil.java index e47802ac62..f9320b64c9 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/SelectorUtil.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/SelectorUtil.java @@ -48,7 +48,7 @@ final class SelectorUtil { } } catch (SecurityException e) { if (logger.isDebugEnabled()) { - logger.debug("Unable to get/set System Property '" + key + "'", e); + logger.debug("Unable to get/set System Property '" + key + '\'', e); } } if (logger.isDebugEnabled()) { diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java index 84ebb499c9..49ff2b87a5 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java @@ -32,6 +32,10 @@ import io.netty.channel.ChannelOutboundMessageHandler; import io.netty.channel.DefaultEventExecutorGroup; import io.netty.channel.EventExecutorGroup; import io.netty.channel.EventLoopGroup; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.HashSet; import java.util.Queue; @@ -43,11 +47,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - public class LocalTransportThreadModelTest { private static ServerBootstrap sb; @@ -369,7 +368,7 @@ public class LocalTransportThreadModelTest { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { exception.compareAndSet(null, cause); - System.err.print("[" + Thread.currentThread().getName() + "] "); + System.err.print('[' + Thread.currentThread().getName() + "] "); cause.printStackTrace(); super.exceptionCaught(ctx, cause); } @@ -604,7 +603,7 @@ public class LocalTransportThreadModelTest { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { exception.compareAndSet(null, cause); - System.err.print("[" + Thread.currentThread().getName() + "] "); + System.err.print('[' + Thread.currentThread().getName() + "] "); cause.printStackTrace(); super.exceptionCaught(ctx, cause); } diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java index 0ae4c2d7b7..3e296ae593 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java @@ -141,7 +141,7 @@ public class LocalTransportThreadModelTest2 { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { for (int i = 0; i < messageCountPerRun; i ++) { - lastWriteFuture = ctx.channel().write(name + " " + i); + lastWriteFuture = ctx.channel().write(name + ' ' + i); } }