From d0912f27091e4548466df81f545c017a25c9d256 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 2 Jul 2014 19:04:11 +0900 Subject: [PATCH] Fix most inspector warnings Motivation: It's good to minimize potentially broken windows. Modifications: Fix most inspector warnings from our profile Update IntObjectHashMap Result: Cleaner code --- .fbfilter.xml | 65 ------------------- .../AbstractReferenceCountedByteBuf.java | 1 - .../io/netty/buffer/ByteBufInputStream.java | 4 +- .../io/netty/buffer/CompositeByteBuf.java | 2 - .../netty/buffer/FixedCompositeByteBuf.java | 4 +- .../java/io/netty/buffer/PooledByteBuf.java | 1 - .../io/netty/buffer/PooledDirectByteBuf.java | 2 +- .../io/netty/buffer/PooledHeapByteBuf.java | 2 +- .../buffer/PooledUnsafeDirectByteBuf.java | 2 +- .../netty/buffer/ReadOnlyByteBufferBuf.java | 4 +- .../buffer/ReadOnlyUnsafeDirectByteBuf.java | 2 +- .../java/io/netty/buffer/SlicedByteBuf.java | 2 +- .../netty/buffer/UnpooledDirectByteBuf.java | 4 +- .../io/netty/buffer/UnpooledHeapByteBuf.java | 2 +- .../buffer/UnpooledUnsafeDirectByteBuf.java | 2 +- .../java/io/netty/buffer/WrappedByteBuf.java | 1 + .../io/netty/buffer/AbstractByteBufTest.java | 13 ++-- .../buffer/AbstractCompositeByteBufTest.java | 5 +- .../io/netty/buffer/DuplicateByteBufTest.java | 9 --- .../io/netty/buffer/ReadOnlyByteBufTest.java | 6 +- .../java/io/netty/buffer/UnpooledTest.java | 32 ++++----- .../codec/dns/DnsResponseException.java | 2 + .../codec/http/HttpContentCompressor.java | 1 + .../netty/handler/codec/http/HttpHeaders.java | 1 + .../handler/codec/http/HttpObjectDecoder.java | 3 +- .../handler/codec/http/cors/CorsConfig.java | 2 +- .../multipart/CaseIgnoringComparator.java | 24 ++++++- .../multipart/DefaultHttpDataFactory.java | 15 +++-- .../HttpPostMultipartRequestDecoder.java | 25 +++---- .../multipart/HttpPostRequestDecoder.java | 3 +- .../HttpPostStandardRequestDecoder.java | 8 +-- .../InterfaceHttpPostRequestDecoder.java | 13 ++-- ...bSocketServerProtocolHandshakeHandler.java | 3 +- .../codec/rtsp/RtspRequestEncoder.java | 4 +- .../codec/rtsp/RtspResponseEncoder.java | 5 +- .../codec/spdy/SpdyHeaderBlockRawEncoder.java | 4 +- .../netty/handler/codec/spdy/SpdySession.java | 6 +- .../codec/http/HttpChunkedInputTest.java | 2 +- .../codec/http/HttpHeaderDateFormatTest.java | 33 +++++----- .../codec/http/HttpObjectAggregatorTest.java | 5 +- .../codec/http/HttpRequestDecoderTest.java | 1 - .../codec/http/HttpResponseEncoderTest.java | 2 +- .../codec/http/cors/CorsHandlerTest.java | 4 +- .../codec/spdy/SpdySessionHandlerTest.java | 2 +- .../binary/BinaryMemcacheResponseStatus.java | 3 +- .../codec/socks/SocksAuthRequestDecoder.java | 3 +- .../codec/socks/SocksAuthResponseDecoder.java | 3 +- .../codec/socks/SocksCmdRequestDecoder.java | 4 +- .../codec/socks/SocksCmdResponseDecoder.java | 3 +- .../codec/socks/SocksInitRequestDecoder.java | 3 +- .../codec/socks/SocksInitResponseDecoder.java | 3 +- .../codec/socks/SocksCommonTestUtils.java | 1 + .../codec/stomp/StompSubframeDecoderTest.java | 6 +- .../handler/codec/DefaultTextHeaders.java | 3 - .../io/netty/handler/codec/base64/Base64.java | 2 +- .../codec/compression/Bzip2Decoder.java | 4 +- .../handler/codec/compression/Crc32c.java | 4 +- .../handler/codec/compression/Snappy.java | 19 +++--- .../marshalling/ChannelBufferByteInput.java | 2 +- .../marshalling/ChannelBufferByteOutput.java | 2 +- .../CompatibleMarshallingDecoder.java | 7 +- .../codec/marshalling/LimitingByteInput.java | 2 +- .../ClassLoaderClassResolver.java | 2 +- .../CompactObjectInputStream.java | 2 +- .../codec/serialization/SoftReferenceMap.java | 2 +- .../codec/serialization/WeakReferenceMap.java | 2 +- .../codec/bytes/ByteArrayDecoderTest.java | 3 - .../codec/compression/JdkZlibTest.java | 1 + .../codec/compression/ZlibCrossTest2.java | 1 + .../netty/util/AbstractReferenceCounted.java | 1 - .../io/netty/util/DefaultAttributeMap.java | 2 +- .../java/io/netty/util/HashedWheelTimer.java | 8 +-- .../src/main/java/io/netty/util/Recycler.java | 4 +- .../src/main/java/io/netty/util/Version.java | 2 +- .../util/collection/IntObjectHashMap.java | 30 ++++++--- .../concurrent/DefaultFutureListeners.java | 2 +- .../netty/util/concurrent/DefaultPromise.java | 7 +- .../util/concurrent/ScheduledFuture.java | 1 + .../io/netty/util/internal/EmptyArrays.java | 1 + .../util/internal/PlatformDependent0.java | 3 +- .../util/internal/SystemPropertyUtil.java | 2 +- .../logging/InternalLoggerFactory.java | 11 +++- .../util/internal/logging/Log4JLogger.java | 2 +- .../util/internal/logging/Slf4JLogger.java | 10 +-- .../internal/logging/Slf4JLoggerFactory.java | 2 +- .../netty/util/DefaultAttributeMapTest.java | 6 +- .../test/java/io/netty/util/RecyclerTest.java | 6 +- .../util/collection/IntObjectHashMapTest.java | 14 ++-- .../internal/AppendableCharSequenceTest.java | 2 +- .../internal/TypeParameterMatcherTest.java | 4 -- .../io/netty/example/echo/EchoClient.java | 2 - .../example/http/cors/OkResponseHandler.java | 6 +- .../http/file/HttpStaticFileServer.java | 2 +- .../file/HttpStaticFileServerHandler.java | 7 +- .../HttpHelloWorldServerHandler.java | 6 +- .../http/snoop/HttpSnoopClientHandler.java | 2 +- .../example/http/snoop/HttpSnoopServer.java | 2 +- .../http/snoop/HttpSnoopServerHandler.java | 7 +- .../http/upload/HttpUploadClientHandler.java | 2 +- .../example/http/upload/HttpUploadServer.java | 2 +- .../http/upload/HttpUploadServerHandler.java | 1 + .../server/WebSocketServerHandler.java | 10 +-- .../netty/example/spdy/client/SpdyClient.java | 2 +- .../io/netty/example/telnet/TelnetServer.java | 2 +- .../rendezvousBytes/ByteEchoPeerBase.java | 4 +- example/src/main/resources/cors/cors.html | 6 +- .../AbstractTrafficShapingHandler.java | 5 +- pom.xml | 4 +- .../epoll/EpollChannelOutboundBuffer.java | 3 +- .../channel/epoll/EpollDatagramChannel.java | 7 +- .../epoll/EpollDatagramChannelConfig.java | 10 +-- .../epoll/EpollSocketChannelConfig.java | 5 +- .../rxtx/DefaultRxtxChannelConfig.java | 2 +- .../channel/sctp/nio/NioSctpChannel.java | 13 ++-- .../sctp/nio/NioSctpServerChannel.java | 2 +- .../channel/sctp/oio/OioSctpChannel.java | 6 +- .../sctp/oio/OioSctpServerChannel.java | 2 +- .../udt/nio/NioUdtByteConnectorChannel.java | 3 +- .../netty/channel/udt/nio/NioUdtProvider.java | 12 ++-- .../nio/NioUdtByteAcceptorChannelTest.java | 2 +- .../nio/NioUdtByteConnectorChannelTest.java | 4 +- .../nio/NioUdtMessageAcceptorChannelTest.java | 2 +- .../NioUdtMessageConnectorChannelTest.java | 2 +- .../netty/test/udt/util/CaliperMeasure.java | 4 +- .../io/netty/test/udt/util/CaliperRunner.java | 9 +-- .../java/io/netty/test/udt/util/UnitHelp.java | 6 +- .../io/netty/bootstrap/ServerBootstrap.java | 1 - .../netty/channel/ChannelHandlerAppender.java | 1 - .../channel/CombinedChannelDuplexHandler.java | 1 - .../io/netty/channel/DefaultChannelId.java | 13 ++-- .../io/netty/channel/FailedChannelFuture.java | 2 +- .../netty/channel/SucceededChannelFuture.java | 2 +- .../ThreadLocalPooledDirectByteBuf.java | 4 +- .../channel/ThreadPerChannelEventLoop.java | 1 - .../io/netty/channel/VoidChannelPromise.java | 2 +- .../io/netty/channel/group/ChannelGroup.java | 2 + .../netty/channel/group/ChannelMatchers.java | 4 +- .../group/DefaultChannelGroupFuture.java | 4 +- .../io/netty/channel/nio/NioEventLoop.java | 4 +- .../channel/oio/OioByteStreamChannel.java | 8 +-- .../socket/ChannelInputShutdownEvent.java | 1 + .../socket/DefaultDatagramChannelConfig.java | 10 +-- .../socket/nio/NioDatagramChannel.java | 6 +- .../channel/socket/nio/NioSocketChannel.java | 6 +- .../nio/NioSocketChannelOutboundBuffer.java | 2 +- .../socket/oio/OioDatagramChannel.java | 3 +- .../channel/socket/oio/OioSocketChannel.java | 2 +- .../java/io/netty/channel/LoggingHandler.java | 29 ++++----- .../ThreadPerChannelEventLoopGroupTest.java | 2 +- .../netty/channel/local/LocalChannelTest.java | 4 +- 150 files changed, 377 insertions(+), 443 deletions(-) delete mode 100644 .fbfilter.xml diff --git a/.fbfilter.xml b/.fbfilter.xml deleted file mode 100644 index 9e350abcf9..0000000000 --- a/.fbfilter.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/buffer/src/main/java/io/netty/buffer/AbstractReferenceCountedByteBuf.java b/buffer/src/main/java/io/netty/buffer/AbstractReferenceCountedByteBuf.java index 06df36de74..c3e1f5a08b 100644 --- a/buffer/src/main/java/io/netty/buffer/AbstractReferenceCountedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/AbstractReferenceCountedByteBuf.java @@ -37,7 +37,6 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf { refCntUpdater = updater; } - @SuppressWarnings("FieldMayBeFinal") private volatile int refCnt = 1; protected AbstractReferenceCountedByteBuf(int maxCapacity) { diff --git a/buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java b/buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java index 46b11b090c..56496fadf4 100644 --- a/buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java +++ b/buffer/src/main/java/io/netty/buffer/ByteBufInputStream.java @@ -189,7 +189,7 @@ public class ByteBufInputStream extends InputStream implements DataInput { loop: while (true) { if (!buffer.isReadable()) { - return (lineBuf.length() > 0) ? lineBuf.toString() : null; + return lineBuf.length() > 0 ? lineBuf.toString() : null; } int c = buffer.readUnsignedByte(); @@ -198,7 +198,7 @@ public class ByteBufInputStream extends InputStream implements DataInput { break loop; case '\r': - if (buffer.isReadable() && buffer.getUnsignedByte(buffer.readerIndex()) == '\n') { + if (buffer.isReadable() && (char) buffer.getUnsignedByte(buffer.readerIndex()) == '\n') { buffer.skipBytes(1); } break loop; diff --git a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java index a9088a21c4..818c97569f 100644 --- a/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java @@ -289,7 +289,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf { ByteBuf consolidated = allocBuffer(capacity); // We're not using foreach to avoid creating an iterator. - // noinspection ForLoopReplaceableByForEach for (int i = 0; i < numComponents; i ++) { Component c = components.get(i); ByteBuf b = c.buf; @@ -1098,7 +1097,6 @@ public class CompositeByteBuf extends AbstractReferenceCountedByteBuf { } else { int count = 0; int componentsCount = components.size(); - //noinspection ForLoopReplaceableByForEach for (int i = 0; i < componentsCount; i++) { Component c = components.get(i); count += c.buf.nioBufferCount(); diff --git a/buffer/src/main/java/io/netty/buffer/FixedCompositeByteBuf.java b/buffer/src/main/java/io/netty/buffer/FixedCompositeByteBuf.java index ab02d14e96..816c0b41de 100644 --- a/buffer/src/main/java/io/netty/buffer/FixedCompositeByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/FixedCompositeByteBuf.java @@ -41,7 +41,7 @@ final class FixedCompositeByteBuf extends AbstractReferenceCountedByteBuf { private final Object[] buffers; private final boolean direct; - public FixedCompositeByteBuf(ByteBufAllocator allocator, ByteBuf... buffers) { + FixedCompositeByteBuf(ByteBufAllocator allocator, ByteBuf... buffers) { super(Integer.MAX_VALUE); if (buffers.length == 0) { this.buffers = EMPTY; @@ -204,7 +204,6 @@ final class FixedCompositeByteBuf extends AbstractReferenceCountedByteBuf { private Component findComponent(int index) { int readable = 0; - //noinspection ForLoopReplaceableByForEach for (int i = 0 ; i < buffers.length; i++) { Component comp = null; ByteBuf b; @@ -545,7 +544,6 @@ final class FixedCompositeByteBuf extends AbstractReferenceCountedByteBuf { @Override protected void deallocate() { - //noinspection ForLoopReplaceableByForEach for (int i = 0; i < buffers.length; i++) { buffer(i).release(); } diff --git a/buffer/src/main/java/io/netty/buffer/PooledByteBuf.java b/buffer/src/main/java/io/netty/buffer/PooledByteBuf.java index 2a993ff6ac..af36ef7eaf 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/PooledByteBuf.java @@ -147,7 +147,6 @@ abstract class PooledByteBuf extends AbstractReferenceCountedByteBuf { } } - @SuppressWarnings("unchecked") private void recycle() { recyclerHandle.recycle(this); } diff --git a/buffer/src/main/java/io/netty/buffer/PooledDirectByteBuf.java b/buffer/src/main/java/io/netty/buffer/PooledDirectByteBuf.java index e45864b04e..bd07ddd489 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledDirectByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/PooledDirectByteBuf.java @@ -308,7 +308,7 @@ final class PooledDirectByteBuf extends PooledByteBuf { tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpBuf); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } diff --git a/buffer/src/main/java/io/netty/buffer/PooledHeapByteBuf.java b/buffer/src/main/java/io/netty/buffer/PooledHeapByteBuf.java index f48c5cc160..cd1e595b60 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledHeapByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/PooledHeapByteBuf.java @@ -232,7 +232,7 @@ final class PooledHeapByteBuf extends PooledByteBuf { index = idx(index); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length)); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } diff --git a/buffer/src/main/java/io/netty/buffer/PooledUnsafeDirectByteBuf.java b/buffer/src/main/java/io/netty/buffer/PooledUnsafeDirectByteBuf.java index efb3bb4308..a22777a05a 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledUnsafeDirectByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/PooledUnsafeDirectByteBuf.java @@ -309,7 +309,7 @@ final class PooledUnsafeDirectByteBuf extends PooledByteBuf { tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpBuf); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } diff --git a/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBufferBuf.java b/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBufferBuf.java index 31a9fc8066..a4643f6248 100644 --- a/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBufferBuf.java +++ b/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBufferBuf.java @@ -36,7 +36,7 @@ class ReadOnlyByteBufferBuf extends AbstractReferenceCountedByteBuf { private final ByteBufAllocator allocator; private ByteBuffer tmpNioBuf; - public ReadOnlyByteBufferBuf(ByteBufAllocator allocator, ByteBuffer buffer) { + ReadOnlyByteBufferBuf(ByteBufAllocator allocator, ByteBuffer buffer) { super(buffer.remaining()); if (!buffer.isReadOnly()) { throw new IllegalArgumentException("must be a readonly buffer: " + StringUtil.simpleClassName(buffer)); @@ -276,7 +276,7 @@ class ReadOnlyByteBufferBuf extends AbstractReferenceCountedByteBuf { ByteBuffer src; try { src = (ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { throw new IndexOutOfBoundsException("Too many bytes to read - Need " + (index + length)); } diff --git a/buffer/src/main/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBuf.java b/buffer/src/main/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBuf.java index 7093b4f28b..f93b7dc2e4 100644 --- a/buffer/src/main/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/ReadOnlyUnsafeDirectByteBuf.java @@ -30,7 +30,7 @@ final class ReadOnlyUnsafeDirectByteBuf extends ReadOnlyByteBufferBuf { private static final boolean NATIVE_ORDER = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; private final long memoryAddress; - public ReadOnlyUnsafeDirectByteBuf(ByteBufAllocator allocator, ByteBuffer buffer) { + ReadOnlyUnsafeDirectByteBuf(ByteBufAllocator allocator, ByteBuffer buffer) { super(allocator, buffer); memoryAddress = PlatformDependent.directBufferAddress(buffer); } diff --git a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java index bdcf6798f3..4c109fe62e 100644 --- a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java @@ -39,7 +39,7 @@ public class SlicedByteBuf extends AbstractDerivedByteBuf { public SlicedByteBuf(ByteBuf buffer, int index, int length) { super(length); if (index < 0 || index > buffer.capacity() - length) { - throw new IndexOutOfBoundsException(buffer.toString() + ".slice(" + index + ", " + length + ')'); + throw new IndexOutOfBoundsException(buffer + ".slice(" + index + ", " + length + ')'); } if (buffer instanceof SlicedByteBuf) { diff --git a/buffer/src/main/java/io/netty/buffer/UnpooledDirectByteBuf.java b/buffer/src/main/java/io/netty/buffer/UnpooledDirectByteBuf.java index f92cd3c10b..1414c8ee8e 100644 --- a/buffer/src/main/java/io/netty/buffer/UnpooledDirectByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/UnpooledDirectByteBuf.java @@ -535,7 +535,7 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf { tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpNioBuf); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } @@ -556,7 +556,7 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf { ByteBuffer src; try { src = (ByteBuffer) buffer.duplicate().clear().position(index).limit(index + length); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { throw new IndexOutOfBoundsException("Too many bytes to read - Need " + (index + length)); } diff --git a/buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java b/buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java index 113160a252..a854319731 100644 --- a/buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java @@ -254,7 +254,7 @@ public class UnpooledHeapByteBuf extends AbstractReferenceCountedByteBuf { ensureAccessible(); try { return in.read((ByteBuffer) internalNioBuffer().clear().position(index).limit(index + length)); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } diff --git a/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeDirectByteBuf.java b/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeDirectByteBuf.java index 345291c84a..954c320bd5 100644 --- a/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeDirectByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/UnpooledUnsafeDirectByteBuf.java @@ -444,7 +444,7 @@ public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf tmpBuf.clear().position(index).limit(index + length); try { return in.read(tmpBuf); - } catch (ClosedChannelException e) { + } catch (ClosedChannelException ignored) { return -1; } } diff --git a/buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java b/buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java index b730aa5ae4..eae17e0e74 100644 --- a/buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java @@ -773,6 +773,7 @@ public class WrappedByteBuf extends ByteBuf { } @Override + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") public boolean equals(Object obj) { return buf.equals(obj); } diff --git a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java index 2e167aa0fc..23560dbe08 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java @@ -18,10 +18,8 @@ package io.netty.buffer; import io.netty.util.CharsetUtil; import io.netty.util.IllegalReferenceCountException; import org.junit.After; -import org.junit.Assert; import org.junit.Assume; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -1477,6 +1475,7 @@ public abstract class AbstractByteBufTest { } @Test + @SuppressWarnings("ObjectEqualsNull") public void testEquals() { assertFalse(buffer.equals(null)); assertFalse(buffer.equals(new Object())); @@ -1728,7 +1727,6 @@ public abstract class AbstractByteBufTest { assertThat(lastIndex.get(), is(CAPACITY / 4)); } - @Ignore @Test public void testInternalNioBuffer() { testInternalNioBuffer(128); @@ -1796,7 +1794,7 @@ public abstract class AbstractByteBufTest { return; } } - Assert.assertArrayEquals(bytes, channel.writtenBytes()); + assertArrayEquals(bytes, channel.writtenBytes()); latch.countDown(); } try { @@ -1850,7 +1848,7 @@ public abstract class AbstractByteBufTest { return; } } - Assert.assertArrayEquals(bytes, out.toByteArray()); + assertArrayEquals(bytes, out.toByteArray()); latch.countDown(); } try { @@ -1899,11 +1897,11 @@ public abstract class AbstractByteBufTest { byte[] array = new byte[8]; buf.readBytes(array); - Assert.assertArrayEquals(bytes, array); + assertArrayEquals(bytes, array); Arrays.fill(array, (byte) 0); buf.getBytes(0, array); - Assert.assertArrayEquals(bytes, array); + assertArrayEquals(bytes, array); latch.countDown(); } @@ -1929,6 +1927,7 @@ public abstract class AbstractByteBufTest { } @Test + @SuppressWarnings("ForLoopThatDoesntUseLoopVariable") public void testNioBufferExposeOnlyRegion() { final ByteBuf buffer = releaseLater(newBuffer(8)); byte[] data = new byte[8]; diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java index a943f1f05d..72432ab0af 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java @@ -71,8 +71,7 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest { buffers.add(EMPTY_BUFFER); } - buffer = Unpooled.wrappedBuffer( - Integer.MAX_VALUE, buffers.toArray(new ByteBuf[buffers.size()])).order(order); + buffer = wrappedBuffer(Integer.MAX_VALUE, buffers.toArray(new ByteBuf[buffers.size()])).order(order); // Truncate to the requested capacity. buffer.capacity(length); @@ -802,7 +801,7 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest { CompositeByteBuf cbuf = releaseLater(compositeBuffer()); int len = 8 * 4; for (int i = 0; i < len; i += 4) { - ByteBuf buf = Unpooled.buffer().writeInt(i); + ByteBuf buf = buffer().writeInt(i); cbuf.capacity(cbuf.writerIndex()).addComponent(buf).writerIndex(i + 4); } cbuf.writeByte(1); diff --git a/buffer/src/test/java/io/netty/buffer/DuplicateByteBufTest.java b/buffer/src/test/java/io/netty/buffer/DuplicateByteBufTest.java index ba957489be..5dad9f13cb 100644 --- a/buffer/src/test/java/io/netty/buffer/DuplicateByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/DuplicateByteBufTest.java @@ -15,7 +15,6 @@ */ package io.netty.buffer; -import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.*; @@ -44,14 +43,6 @@ public class DuplicateByteBufTest extends AbstractByteBufTest { new DuplicatedByteBuf(null); } - @Ignore - @Test - // Test which shows bug - // https://github.com/netty/netty/issues/1802 - public void testInternalNioBuffer() { - super.testInternalNioBuffer(); - } - // See https://github.com/netty/netty/issues/1800 @Test public void testIncreaseCapacityWrapped() { diff --git a/buffer/src/test/java/io/netty/buffer/ReadOnlyByteBufTest.java b/buffer/src/test/java/io/netty/buffer/ReadOnlyByteBufTest.java index c944cdd134..5023821a54 100644 --- a/buffer/src/test/java/io/netty/buffer/ReadOnlyByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/ReadOnlyByteBufTest.java @@ -46,15 +46,15 @@ public class ReadOnlyByteBufTest { @Test public void testUnwrap() { ByteBuf buf = buffer(1); - assertSame(buf, Unpooled.unmodifiableBuffer(buf).unwrap()); + assertSame(buf, unmodifiableBuffer(buf).unwrap()); } @Test public void shouldHaveSameByteOrder() { ByteBuf buf = buffer(1); - assertSame(BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order()); + assertSame(BIG_ENDIAN, unmodifiableBuffer(buf).order()); buf = buf.order(LITTLE_ENDIAN); - assertSame(LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order()); + assertSame(LITTLE_ENDIAN, unmodifiableBuffer(buf).order()); } @Test diff --git a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java index 4b993891d0..0b2e5dc816 100644 --- a/buffer/src/test/java/io/netty/buffer/UnpooledTest.java +++ b/buffer/src/test/java/io/netty/buffer/UnpooledTest.java @@ -445,8 +445,8 @@ public class UnpooledTest { assertEquals(4, buffer.readInt()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyInt(null).capacity()); - assertEquals(0, Unpooled.copyInt(EMPTY_INTS).capacity()); + assertEquals(0, copyInt(null).capacity()); + assertEquals(0, copyInt(EMPTY_INTS).capacity()); } @Test @@ -465,8 +465,8 @@ public class UnpooledTest { assertEquals(4, buffer.readShort()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyShort((short[]) null).capacity()); - assertEquals(0, Unpooled.copyShort(EMPTY_SHORTS).capacity()); + assertEquals(0, copyShort((short[]) null).capacity()); + assertEquals(0, copyShort(EMPTY_SHORTS).capacity()); } @Test @@ -477,8 +477,8 @@ public class UnpooledTest { assertEquals(4, buffer.readShort()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyShort((int[]) null).capacity()); - assertEquals(0, Unpooled.copyShort(EMPTY_INTS).capacity()); + assertEquals(0, copyShort((int[]) null).capacity()); + assertEquals(0, copyShort(EMPTY_INTS).capacity()); } @Test @@ -497,8 +497,8 @@ public class UnpooledTest { assertEquals(4, buffer.readMedium()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyMedium(null).capacity()); - assertEquals(0, Unpooled.copyMedium(EMPTY_INTS).capacity()); + assertEquals(0, copyMedium(null).capacity()); + assertEquals(0, copyMedium(EMPTY_INTS).capacity()); } @Test @@ -517,8 +517,8 @@ public class UnpooledTest { assertEquals(4, buffer.readLong()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyLong(null).capacity()); - assertEquals(0, Unpooled.copyLong(EMPTY_LONGS).capacity()); + assertEquals(0, copyLong(null).capacity()); + assertEquals(0, copyLong(EMPTY_LONGS).capacity()); } @Test @@ -537,8 +537,8 @@ public class UnpooledTest { assertEquals(4, buffer.readFloat(), 0.01); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyFloat(null).capacity()); - assertEquals(0, Unpooled.copyFloat(EMPTY_FLOATS).capacity()); + assertEquals(0, copyFloat(null).capacity()); + assertEquals(0, copyFloat(EMPTY_FLOATS).capacity()); } @Test @@ -557,8 +557,8 @@ public class UnpooledTest { assertEquals(4, buffer.readDouble(), 0.01); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyDouble(null).capacity()); - assertEquals(0, Unpooled.copyDouble(EMPTY_DOUBLES).capacity()); + assertEquals(0, copyDouble(null).capacity()); + assertEquals(0, copyDouble(EMPTY_DOUBLES).capacity()); } @Test @@ -569,8 +569,8 @@ public class UnpooledTest { assertFalse(buffer.readBoolean()); assertFalse(buffer.isReadable()); - assertEquals(0, Unpooled.copyBoolean(null).capacity()); - assertEquals(0, Unpooled.copyBoolean(EMPTY_BOOLEANS).capacity()); + assertEquals(0, copyBoolean(null).capacity()); + assertEquals(0, copyBoolean(EMPTY_BOOLEANS).capacity()); } @Test diff --git a/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsResponseException.java b/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsResponseException.java index e20750eba7..4497463fe5 100644 --- a/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsResponseException.java +++ b/codec-dns/src/main/java/io/netty/handler/codec/dns/DnsResponseException.java @@ -20,6 +20,8 @@ import io.netty.handler.codec.DecoderException; public final class DnsResponseException extends DecoderException { + private static final long serialVersionUID = -8519053051363525286L; + private final DnsResponseCode code; public DnsResponseException(DnsResponseCode code) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java index 3b1bf315ff..87367acd18 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java @@ -124,6 +124,7 @@ public class HttpContentCompressor extends HttpContentEncoder { wrapper, compressionLevel, windowBits, memLevel))); } + @SuppressWarnings("FloatingPointEquality") protected ZlibWrapper determineWrapper(String acceptEncoding) { float starQ = -1.0f; float gzipQ = -1.0f; 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 95c1f146ec..5dc131365b 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 @@ -1203,6 +1203,7 @@ public abstract class HttpHeaders implements Iterable> } } + @SuppressWarnings("deprecation") private static void encode(CharSequence key, CharSequence value, ByteBuf buf) { encodeAscii(key, buf); buf.writeBytes(HEADER_SEPERATOR); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java index 399f1d34a2..c40afa8065 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java @@ -24,6 +24,7 @@ import io.netty.handler.codec.AsciiString; import io.netty.handler.codec.DecoderResult; import io.netty.handler.codec.ReplayingDecoder; import io.netty.handler.codec.TooLongFrameException; +import io.netty.handler.codec.http.HttpObjectDecoder.State; import io.netty.util.internal.AppendableCharSequence; import java.util.List; @@ -101,7 +102,7 @@ import static io.netty.buffer.ByteBufUtil.*; * To implement the decoder of such a derived protocol, extend this class and * implement all abstract methods properly. */ -public abstract class HttpObjectDecoder extends ReplayingDecoder { +public abstract class HttpObjectDecoder extends ReplayingDecoder { private final int maxInitialLineLength; private final int maxHeaderSize; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java index 5f612dc704..7ceff7a54f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfig.java @@ -266,7 +266,7 @@ public final class CorsConfig { * @return {@link Builder} to support method chaining. */ public static Builder withOrigin(final String origin) { - if (origin.equals("*")) { + if ("*".equals(origin)) { return new Builder(); } return new Builder(origin); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java index 6f86d3f911..fb46572e13 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java @@ -18,7 +18,7 @@ package io.netty.handler.codec.http.multipart; import java.io.Serializable; import java.util.Comparator; -final class CaseIgnoringComparator implements Comparator, Serializable { +final class CaseIgnoringComparator implements Comparator, Serializable { private static final long serialVersionUID = 4582133183775373862L; @@ -28,8 +28,26 @@ final class CaseIgnoringComparator implements Comparator, Serializable { } @Override - public int compare(String o1, String o2) { - return o1.compareToIgnoreCase(o2); + public int compare(CharSequence o1, CharSequence o2) { + int o1Length = o1.length(); + int o2Length = o2.length(); + int min = Math.min(o1Length, o2Length); + for (int i = 0; i < min; i++) { + char c1 = o1.charAt(i); + char c2 = o2.charAt(i); + if (c1 != c2) { + c1 = Character.toUpperCase(c1); + c2 = Character.toUpperCase(c2); + if (c1 != c2) { + c1 = Character.toLowerCase(c1); + c2 = Character.toLowerCase(c2); + if (c1 != c2) { + return c1 - c2; + } + } + } + } + return o1Length - o2Length; } private Object readResolve() { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java index 3cea4f1a3b..6391f649f5 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/DefaultHttpDataFactory.java @@ -22,8 +22,10 @@ import io.netty.util.internal.PlatformDependent; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; /** * Default factory giving Attribute and FileUpload according to constructor @@ -145,7 +147,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory { private static void checkHttpDataSize(HttpData data) { try { data.checkSize(data.length()); - } catch (IOException e) { + } catch (IOException ignored) { throw new IllegalArgumentException("Attribute bigger than maxSize allowed"); } } @@ -235,15 +237,18 @@ public class DefaultHttpDataFactory implements HttpDataFactory { @Override public void cleanAllHttpData() { - for (HttpRequest request : requestFileDeleteMap.keySet()) { - List fileToDelete = requestFileDeleteMap.get(request); + Iterator>> i = requestFileDeleteMap.entrySet().iterator(); + while (i.hasNext()) { + Entry> e = i.next(); + i.remove(); + + List fileToDelete = e.getValue(); if (fileToDelete != null) { - for (HttpData data: fileToDelete) { + for (HttpData data : fileToDelete) { data.delete(); } fileToDelete.clear(); } - requestFileDeleteMap.remove(request); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java index 28f41b5887..10481919bc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoder.java @@ -106,7 +106,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest /** * Used in Multipart */ - private Map currentFieldAttributes; + private Map currentFieldAttributes; /** * The current FileUpload that is currently in decode process @@ -516,7 +516,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest // load data try { loadFieldMultipart(multipartDataBoundary); - } catch (NotEnoughDataDecoderException e) { + } catch (NotEnoughDataDecoderException ignored) { return null; } Attribute finalAttribute = currentAttribute; @@ -561,7 +561,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e) { + } catch (SeekAheadNoBackArrayException ignored) { try { skipControlCharactersStandard(); } catch (IndexOutOfBoundsException e1) { @@ -608,7 +608,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest int readerIndex = undecodedChunk.readerIndex(); try { skipControlCharacters(); - } catch (NotEnoughDataDecoderException e1) { + } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; } @@ -616,7 +616,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest String newline; try { newline = readDelimiter(delimiter); - } catch (NotEnoughDataDecoderException e) { + } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; } @@ -648,7 +648,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest private InterfaceHttpData findMultipartDisposition() { int readerIndex = undecodedChunk.readerIndex(); if (currentStatus == MultiPartStatus.DISPOSITION) { - currentFieldAttributes = new TreeMap(CaseIgnoringComparator.INSTANCE); + currentFieldAttributes = new TreeMap(CaseIgnoringComparator.INSTANCE); } // read many lines until empty line with newline found! Store all data while (!skipOneLine()) { @@ -656,7 +656,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest try { skipControlCharacters(); newline = readLine(); - } catch (NotEnoughDataDecoderException e) { + } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; } @@ -842,7 +842,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest size = lengthAttribute != null ? Long.parseLong(lengthAttribute.getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { size = 0; } try { @@ -991,7 +991,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e1) { + } catch (SeekAheadNoBackArrayException ignored) { return readLineStandard(); } int readerIndex = undecodedChunk.readerIndex(); @@ -1142,7 +1142,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e1) { + } catch (SeekAheadNoBackArrayException ignored) { return readDelimiterStandard(delimiter); } int readerIndex = undecodedChunk.readerIndex(); @@ -1371,7 +1371,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e1) { + } catch (SeekAheadNoBackArrayException ignored) { readFileUploadByteMultipartStandard(delimiter); return; } @@ -1592,7 +1592,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e1) { + } catch (SeekAheadNoBackArrayException ignored) { loadFieldMultipartStandard(delimiter); return; } @@ -1699,6 +1699,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest * * @return the cleaned String */ + @SuppressWarnings("IfStatementWithIdenticalBranches") private static String cleanString(String field) { StringBuilder sb = new StringBuilder(field.length()); for (int i = 0; i < field.length(); i++) { 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 c3820df046..d0e66de839 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 @@ -156,7 +156,8 @@ public class HttpPostRequestDecoder implements InterfaceHttpPostRequestDecoder { String[] headerContentType = splitHeaderContentType(contentType); if (headerContentType[0].toLowerCase().startsWith( HttpHeaders.Values.MULTIPART_FORM_DATA)) { - int mrank = 1, crank = 2; + int mrank; + int crank; if (headerContentType[1].toLowerCase().startsWith( HttpHeaders.Values.BOUNDARY)) { mrank = 1; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java index 585ad0c1b3..d63f0575fd 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostStandardRequestDecoder.java @@ -511,7 +511,7 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e1) { + } catch (SeekAheadNoBackArrayException ignored) { parseBodyAttributesStandard(); return; } @@ -659,11 +659,11 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD SeekAheadOptimize sao; try { sao = new SeekAheadOptimize(undecodedChunk); - } catch (SeekAheadNoBackArrayException e) { + } catch (SeekAheadNoBackArrayException ignored) { try { skipControlCharactersStandard(); - } catch (IndexOutOfBoundsException e1) { - throw new NotEnoughDataDecoderException(e1); + } catch (IndexOutOfBoundsException e) { + throw new NotEnoughDataDecoderException(e); } return; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InterfaceHttpPostRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InterfaceHttpPostRequestDecoder.java index 39fc9c6d02..a832c883b1 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InterfaceHttpPostRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/InterfaceHttpPostRequestDecoder.java @@ -55,7 +55,7 @@ public interface InterfaceHttpPostRequestDecoder { * @throws HttpPostRequestDecoder.NotEnoughDataDecoderException * Need more chunks */ - List getBodyHttpDatas() throws HttpPostRequestDecoder.NotEnoughDataDecoderException; + List getBodyHttpDatas(); /** * This getMethod returns a List of all HttpDatas with the given name from @@ -68,7 +68,7 @@ public interface InterfaceHttpPostRequestDecoder { * @throws HttpPostRequestDecoder.NotEnoughDataDecoderException * need more chunks */ - List getBodyHttpDatas(String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException; + List getBodyHttpDatas(String name); /** * This getMethod returns the first InterfaceHttpData with the given name from @@ -82,7 +82,7 @@ public interface InterfaceHttpPostRequestDecoder { * @throws HttpPostRequestDecoder.NotEnoughDataDecoderException * need more chunks */ - InterfaceHttpData getBodyHttpData(String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException; + InterfaceHttpData getBodyHttpData(String name); /** * Initialized the internals from a new chunk @@ -93,8 +93,7 @@ public interface InterfaceHttpPostRequestDecoder { * if there is a problem with the charset decoding or other * errors */ - InterfaceHttpPostRequestDecoder offer(HttpContent content) - throws HttpPostRequestDecoder.ErrorDataDecoderException; + InterfaceHttpPostRequestDecoder offer(HttpContent content); /** * True if at current getStatus, there is an available decoded @@ -106,7 +105,7 @@ public interface InterfaceHttpPostRequestDecoder { * @throws HttpPostRequestDecoder.EndOfDataDecoderException * No more data will be available */ - boolean hasNext() throws HttpPostRequestDecoder.EndOfDataDecoderException; + boolean hasNext(); /** * Returns the next available InterfaceHttpData or null if, at the time it @@ -120,7 +119,7 @@ public interface InterfaceHttpPostRequestDecoder { * @throws HttpPostRequestDecoder.EndOfDataDecoderException * No more data will be available */ - InterfaceHttpData next() throws HttpPostRequestDecoder.EndOfDataDecoderException; + InterfaceHttpData next(); /** * Destroy the {@link InterfaceHttpPostRequestDecoder} and release all it resources. After this method diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java index 4dfbd6fb29..57704ec7d6 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java @@ -22,7 +22,6 @@ import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpRequest; -import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpRequest; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.ssl.SslHandler; @@ -100,7 +99,7 @@ class WebSocketServerProtocolHandshakeHandler extends ChannelInboundHandlerAdapt // SSL in use so use Secure WebSockets protocol = "wss"; } - return protocol + "://" + req.headers().get(HttpHeaders.Names.HOST) + path; + return protocol + "://" + req.headers().get(Names.HOST) + path; } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java index 0c0fb334ae..da13aa89d9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java @@ -37,8 +37,8 @@ public class RtspRequestEncoder extends RtspObjectEncoder { } @Override - protected void encodeInitialLine(ByteBuf buf, HttpRequest request) - throws Exception { + @SuppressWarnings("deprecation") + protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { HttpHeaders.encodeAscii(request.method().toString(), buf); buf.writeByte(SP); buf.writeBytes(request.uri().getBytes(CharsetUtil.UTF_8)); diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java index 4d424238bf..53968e405c 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java @@ -26,7 +26,6 @@ import static io.netty.handler.codec.http.HttpConstants.*; /** * Encodes an RTSP response represented in {@link FullHttpResponse} into * a {@link ByteBuf}. - */ public class RtspResponseEncoder extends RtspObjectEncoder { private static final byte[] CRLF = { CR, LF }; @@ -37,8 +36,8 @@ public class RtspResponseEncoder extends RtspObjectEncoder { } @Override - protected void encodeInitialLine(ByteBuf buf, HttpResponse response) - throws Exception { + @SuppressWarnings("deprecation") + protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { HttpHeaders.encodeAscii(response.protocolVersion().toString(), buf); buf.writeByte(SP); buf.writeBytes(String.valueOf(response.status().code()).getBytes(CharsetUtil.US_ASCII)); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java index 923cbe94ec..81f9e6f5a6 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java @@ -33,11 +33,11 @@ public class SpdyHeaderBlockRawEncoder extends SpdyHeaderBlockEncoder { this.version = version.getVersion(); } - private void setLengthField(ByteBuf buffer, int writerIndex, int length) { + private static void setLengthField(ByteBuf buffer, int writerIndex, int length) { buffer.setInt(writerIndex, length); } - private void writeLengthField(ByteBuf buffer, int length) { + private static void writeLengthField(ByteBuf buffer, int length) { buffer.writeInt(length); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java index 6c6a5a3408..e447bda73f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.spdy; import io.netty.channel.ChannelPromise; import io.netty.util.internal.PlatformDependent; +import java.io.Serializable; import java.util.Comparator; import java.util.Map; import java.util.Queue; @@ -320,7 +321,10 @@ final class SpdySession { } } - private final class PriorityComparator implements Comparator { + private final class PriorityComparator implements Comparator, Serializable { + + private static final long serialVersionUID = 1161471649740544848L; + @Override public int compare(Integer id1, Integer id2) { StreamState state1 = activeStreams.get(id1); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java index 87e321e078..fbf607536a 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java @@ -118,6 +118,6 @@ public class HttpChunkedInputTest { } assertEquals(BYTES.length * inputs.length, read); - assertTrue("Last chunk must be DefaultLastHttpContent", lastHttpContent == LastHttpContent.EMPTY_LAST_CONTENT); + assertSame("Last chunk must be DefaultLastHttpContent", LastHttpContent.EMPTY_LAST_CONTENT, lastHttpContent); } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java index 5a6fe025d9..4f4a6e0fb3 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpHeaderDateFormatTest.java @@ -15,11 +15,12 @@ */ package io.netty.handler.codec.http; +import org.junit.Test; + import java.text.ParseException; import java.util.Date; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.Assert.*; public class HttpHeaderDateFormatTest { /** @@ -35,28 +36,24 @@ public class HttpHeaderDateFormatTest { HttpHeaderDateFormat format = HttpHeaderDateFormat.get(); final Date parsedDateWithSingleDigitDay = format.parse("Sun, 6 Nov 1994 08:49:37 GMT"); - Assert.assertNotNull(parsedDateWithSingleDigitDay); - Assert.assertEquals(DATE, parsedDateWithSingleDigitDay); + assertNotNull(parsedDateWithSingleDigitDay); + assertEquals(DATE, parsedDateWithSingleDigitDay); final Date parsedDateWithDoubleDigitDay = format.parse("Sun, 06 Nov 1994 08:49:37 GMT"); - Assert.assertNotNull(parsedDateWithDoubleDigitDay); - Assert.assertEquals(DATE, parsedDateWithDoubleDigitDay); + assertNotNull(parsedDateWithDoubleDigitDay); + assertEquals(DATE, parsedDateWithDoubleDigitDay); final Date parsedDateWithDashSeparatorSingleDigitDay = format.parse("Sunday, 06-Nov-94 08:49:37 GMT"); - Assert.assertNotNull(parsedDateWithDashSeparatorSingleDigitDay); - Assert.assertEquals(DATE, parsedDateWithDashSeparatorSingleDigitDay); + assertNotNull(parsedDateWithDashSeparatorSingleDigitDay); + assertEquals(DATE, parsedDateWithDashSeparatorSingleDigitDay); final Date parsedDateWithSingleDoubleDigitDay = format.parse("Sunday, 6-Nov-94 08:49:37 GMT"); - Assert.assertNotNull(parsedDateWithSingleDoubleDigitDay); - Assert.assertEquals(DATE, parsedDateWithSingleDoubleDigitDay); + assertNotNull(parsedDateWithSingleDoubleDigitDay); + assertEquals(DATE, parsedDateWithSingleDoubleDigitDay); final Date parsedDateWithoutGMT = format.parse("Sun Nov 6 08:49:37 1994"); - Assert.assertNotNull(parsedDateWithoutGMT); - Assert.assertEquals(DATE, parsedDateWithoutGMT); - } - - private Date parseDate(HttpHeaderDateFormat dateFormat, String dateStr) throws ParseException { - return dateFormat.parse(dateStr); + assertNotNull(parsedDateWithoutGMT); + assertEquals(DATE, parsedDateWithoutGMT); } @Test @@ -64,7 +61,7 @@ public class HttpHeaderDateFormatTest { HttpHeaderDateFormat format = HttpHeaderDateFormat.get(); final String formatted = format.format(DATE); - Assert.assertNotNull(formatted); - Assert.assertEquals("Sun, 06 Nov 1994 08:49:37 GMT", formatted); + assertNotNull(formatted); + assertEquals("Sun, 06 Nov 1994 08:49:37 GMT", formatted); } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java index 5afc5e5413..55800fe2ce 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java @@ -20,6 +20,7 @@ import io.netty.buffer.CompositeByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.handler.codec.DecoderResultProvider; import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.http.HttpHeaders.Names; import io.netty.util.CharsetUtil; @@ -308,7 +309,7 @@ public class HttpObjectAggregatorTest { ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8)); Object inbound = ch.readInbound(); assertThat(inbound, is(instanceOf(FullHttpRequest.class))); - assertTrue(((FullHttpRequest) inbound).getDecoderResult().isFailure()); + assertTrue(((DecoderResultProvider) inbound).decoderResult().isFailure()); assertNull(ch.readInbound()); ch.finish(); } @@ -319,7 +320,7 @@ public class HttpObjectAggregatorTest { ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8)); Object inbound = ch.readInbound(); assertThat(inbound, is(instanceOf(FullHttpResponse.class))); - assertTrue(((FullHttpResponse) inbound).getDecoderResult().isFailure()); + assertTrue(((DecoderResultProvider) inbound).decoderResult().isFailure()); assertNull(ch.readInbound()); ch.finish(); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java index 54ddaafb22..8fa745115d 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpRequestDecoderTest.java @@ -136,7 +136,6 @@ public class HttpRequestDecoderTest { } // if header is done it should produce a HttpRequest - boolean headerDone = a + amount == headerLength; channel.writeInbound(Unpooled.wrappedBuffer(content, a, amount)); a += amount; } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java index 6980458917..ff2b26065a 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseEncoderTest.java @@ -47,7 +47,7 @@ public class HttpResponseEncoderTest { buffer.release(); FileRegion region = channel.readOutbound(); - assertSame(region, FILE_REGION); + assertSame(FILE_REGION, region); region.release(); buffer = channel.readOutbound(); assertEquals("\r\n", buffer.toString(CharsetUtil.US_ASCII)); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java index 5f71a9c79a..de2c611882 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java @@ -78,7 +78,7 @@ public class CorsHandlerTest { @Test public void preflightDeleteRequestWithCustomHeaders() { final CorsConfig config = CorsConfig.withOrigin("http://localhost:8888") - .allowedRequestMethods(HttpMethod.GET, HttpMethod.DELETE) + .allowedRequestMethods(GET, DELETE) .build(); final HttpResponse response = preflightRequest(config, "http://localhost:8888", "content-type, xheader1"); assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), is("http://localhost:8888")); @@ -89,7 +89,7 @@ public class CorsHandlerTest { @Test public void preflightGetRequestWithCustomHeaders() { final CorsConfig config = CorsConfig.withOrigin("http://localhost:8888") - .allowedRequestMethods(HttpMethod.OPTIONS, HttpMethod.GET, HttpMethod.DELETE) + .allowedRequestMethods(OPTIONS, GET, DELETE) .allowedRequestHeaders("content-type", "xheader1") .build(); final HttpResponse response = preflightRequest(config, "http://localhost:8888", "content-type, xheader1"); diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java index a27075666d..85b4a518e2 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java @@ -172,7 +172,7 @@ public class SpdySessionHandlerTest { // a RST_STREAM frame for that Stream-ID sessionHandler.writeInbound(new DefaultSpdyRstStreamFrame(remoteStreamId, 3)); assertNull(sessionHandler.readOutbound()); - remoteStreamId += 2; + //remoteStreamId += 2; // Check if session handler honors UNIDIRECTIONAL streams spdySynStreamFrame.setLast(false); diff --git a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseStatus.java b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseStatus.java index d96737ac14..f2599cee8a 100644 --- a/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseStatus.java +++ b/codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheResponseStatus.java @@ -16,8 +16,7 @@ package io.netty.handler.codec.memcache.binary; /** - * Contains all possible status values a - * {@link BinaryMemcacheResponseHeader} can return. + * Contains all possible status values a {@link BinaryMemcacheResponse} can return. */ public final class BinaryMemcacheResponseStatus { diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java index 6678529856..18634c7ddd 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthRequestDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksAuthRequestDecoder.State; import io.netty.util.CharsetUtil; import java.util.List; @@ -26,7 +27,7 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksAuthRequest}. * Before returning SocksRequest decoder removes itself from pipeline. */ -public class SocksAuthRequestDecoder extends ReplayingDecoder { +public class SocksAuthRequestDecoder extends ReplayingDecoder { private SocksSubnegotiationVersion version; private int fieldLength; diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthResponseDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthResponseDecoder.java index 5674a10c7a..e3107fd1f7 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthResponseDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksAuthResponseDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksAuthResponseDecoder.State; import java.util.List; @@ -25,7 +26,7 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksAuthResponse}. * Before returning SocksResponse decoder removes itself from pipeline. */ -public class SocksAuthResponseDecoder extends ReplayingDecoder { +public class SocksAuthResponseDecoder extends ReplayingDecoder { private SocksSubnegotiationVersion version; private SocksAuthStatus authStatus; diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdRequestDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdRequestDecoder.java index 41f840a12c..518667bde6 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdRequestDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdRequestDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksCmdRequestDecoder.State; import io.netty.util.CharsetUtil; import java.util.List; @@ -26,12 +27,13 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksCmdRequest}. * Before returning SocksRequest decoder removes itself from pipeline. */ -public class SocksCmdRequestDecoder extends ReplayingDecoder { +public class SocksCmdRequestDecoder extends ReplayingDecoder { private SocksProtocolVersion version; private int fieldLength; private SocksCmdType cmdType; private SocksAddressType addressType; + @SuppressWarnings("UnusedDeclaration") private byte reserved; private String host; private int port; diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java index 166ab35e38..0b4bca782a 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksCmdResponseDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksCmdResponseDecoder.State; import io.netty.util.CharsetUtil; import java.util.List; @@ -26,7 +27,7 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksCmdResponse}. * Before returning SocksResponse decoder removes itself from pipeline. */ -public class SocksCmdResponseDecoder extends ReplayingDecoder { +public class SocksCmdResponseDecoder extends ReplayingDecoder { private SocksProtocolVersion version; private int fieldLength; diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java index 5a17c00f8a..6604bb1d77 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitRequestDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksInitRequestDecoder.State; import java.util.ArrayList; import java.util.List; @@ -26,7 +27,7 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksInitRequest}. * Before returning SocksRequest decoder removes itself from pipeline. */ -public class SocksInitRequestDecoder extends ReplayingDecoder { +public class SocksInitRequestDecoder extends ReplayingDecoder { private final List authSchemes = new ArrayList(); private SocksProtocolVersion version; diff --git a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitResponseDecoder.java b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitResponseDecoder.java index e98f0c03e7..f7c4fe6521 100644 --- a/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitResponseDecoder.java +++ b/codec-socks/src/main/java/io/netty/handler/codec/socks/SocksInitResponseDecoder.java @@ -18,6 +18,7 @@ package io.netty.handler.codec.socks; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import io.netty.handler.codec.socks.SocksInitResponseDecoder.State; import java.util.List; @@ -25,7 +26,7 @@ import java.util.List; * Decodes {@link ByteBuf}s into {@link SocksInitResponse}. * Before returning SocksResponse decoder removes itself from pipeline. */ -public class SocksInitResponseDecoder extends ReplayingDecoder { +public class SocksInitResponseDecoder extends ReplayingDecoder { private SocksProtocolVersion version; private SocksAuthScheme authScheme; diff --git a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCommonTestUtils.java b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCommonTestUtils.java index f4a54dbad0..35f81ca363 100644 --- a/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCommonTestUtils.java +++ b/codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCommonTestUtils.java @@ -27,6 +27,7 @@ final class SocksCommonTestUtils { //NOOP } + @SuppressWarnings("deprecation") public static void writeMessageIntoEmbedder(EmbeddedChannel embedder, SocksMessage msg) { ByteBuf buf = Unpooled.buffer(); msg.encodeAsByteBuf(buf); diff --git a/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java b/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java index eef5b4b7ef..d03fa85ea8 100644 --- a/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java +++ b/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java @@ -48,7 +48,7 @@ public class StompSubframeDecoderTest { assertNotNull(frame); assertEquals(StompCommand.CONNECT, frame.command()); StompContentSubframe content = channel.readInbound(); - assertSame(content, LastStompContentSubframe.EMPTY_LAST_CONTENT); + assertSame(LastStompContentSubframe.EMPTY_LAST_CONTENT, content); Object o = channel.readInbound(); assertNull(o); } @@ -123,13 +123,13 @@ public class StompSubframeDecoderTest { assertNotNull(frame); assertEquals(StompCommand.CONNECT, frame.command()); StompContentSubframe content = channel.readInbound(); - assertSame(content, LastStompContentSubframe.EMPTY_LAST_CONTENT); + assertSame(LastStompContentSubframe.EMPTY_LAST_CONTENT, content); StompHeadersSubframe frame2 = channel.readInbound(); assertNotNull(frame2); assertEquals(StompCommand.CONNECTED, frame2.command()); StompContentSubframe content2 = channel.readInbound(); - assertSame(content2, LastStompContentSubframe.EMPTY_LAST_CONTENT); + assertSame(LastStompContentSubframe.EMPTY_LAST_CONTENT, content2); assertNull(channel.readInbound()); } } diff --git a/codec/src/main/java/io/netty/handler/codec/DefaultTextHeaders.java b/codec/src/main/java/io/netty/handler/codec/DefaultTextHeaders.java index 0e7666b5a8..9d36a957a0 100644 --- a/codec/src/main/java/io/netty/handler/codec/DefaultTextHeaders.java +++ b/codec/src/main/java/io/netty/handler/codec/DefaultTextHeaders.java @@ -45,7 +45,6 @@ public class DefaultTextHeaders implements TextHeaders { return Math.abs(hash % BUCKET_SIZE); } - @SuppressWarnings("unchecked") private final HeaderEntry[] entries = new HeaderEntry[BUCKET_SIZE]; private final HeaderEntry head = new HeaderEntry(this); private final boolean ignoreCase; @@ -71,7 +70,6 @@ public class DefaultTextHeaders implements TextHeaders { return name; } - @SuppressWarnings("unchecked") protected CharSequence convertValue(Object value) { if (value == null) { throw new NullPointerException("value"); @@ -195,7 +193,6 @@ public class DefaultTextHeaders implements TextHeaders { } if (headers instanceof DefaultTextHeaders) { - @SuppressWarnings("unchecked") DefaultTextHeaders m = (DefaultTextHeaders) headers; HeaderEntry e = m.head.after; while (e != m.head) { diff --git a/codec/src/main/java/io/netty/handler/codec/base64/Base64.java b/codec/src/main/java/io/netty/handler/codec/base64/Base64.java index f01072f159..e06f67df15 100644 --- a/codec/src/main/java/io/netty/handler/codec/base64/Base64.java +++ b/codec/src/main/java/io/netty/handler/codec/base64/Base64.java @@ -286,7 +286,7 @@ public final class Base64 { (DECODABET[src[srcOffset + 1]] & 0xFF) << 12 | (DECODABET[src[srcOffset + 2]] & 0xFF) << 6 | DECODABET[src[srcOffset + 3]] & 0xFF; - } catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException ignored) { throw new IllegalArgumentException("not encoded in Base64"); } diff --git a/codec/src/main/java/io/netty/handler/codec/compression/Bzip2Decoder.java b/codec/src/main/java/io/netty/handler/codec/compression/Bzip2Decoder.java index 430dfc2607..614dfd7ae7 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/Bzip2Decoder.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/Bzip2Decoder.java @@ -157,7 +157,7 @@ public class Bzip2Decoder extends ByteToMessageDecoder { int huffmanSymbolCount = 0; if (bitNumber > 0) { for (int i = 0; i < 16; i++) { - if ((inUse16 & ((1 << 15) >>> i)) != 0) { + if ((inUse16 & 1 << 15 >>> i) != 0) { for (int j = 0, k = i << 4; j < 16; j++, k++) { if (readBoolean(in)) { huffmanSymbolMap[huffmanSymbolCount++] = (byte) k; @@ -330,7 +330,7 @@ public class Bzip2Decoder extends ByteToMessageDecoder { } this.bitCount = bitCount -= n; - return (bitBuffer >>> bitCount) & ((1 << n) - 1); + return bitBuffer >>> bitCount & (1 << n) - 1; } private boolean readBoolean(ByteBuf in) { diff --git a/codec/src/main/java/io/netty/handler/codec/compression/Crc32c.java b/codec/src/main/java/io/netty/handler/codec/compression/Crc32c.java index b67c20004a..e82380bd4e 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/Crc32c.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/Crc32c.java @@ -93,7 +93,7 @@ class Crc32c implements Checksum { 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351, }; - private static final int LONG_MASK = 0xFFFFFFFF; + private static final long LONG_MASK = 0xFFFFFFFFL; private static final int BYTE_MASK = 0xFF; private int crc = ~0; @@ -121,6 +121,6 @@ class Crc32c implements Checksum { } private static int crc32c(int crc, int b) { - return (crc >>> 8) ^ CRC_TABLE[(crc ^ (b & BYTE_MASK)) & BYTE_MASK]; + return crc >>> 8 ^ CRC_TABLE[(crc ^ b & BYTE_MASK) & BYTE_MASK]; } } diff --git a/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java b/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java index c521c7bd3e..1d61d0c119 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java @@ -57,7 +57,7 @@ public class Snappy { written = 0; } - public void encode(ByteBuf in, ByteBuf out, int length) { + public void encode(final ByteBuf in, final ByteBuf out, final int length) { // Write the preamble length to the output buffer for (int i = 0;; i ++) { int b = length >>> i * 7; @@ -70,15 +70,14 @@ public class Snappy { } int inIndex = in.readerIndex(); - final int baseIndex = in.readerIndex(); - final int maxIndex = length; + final int baseIndex = inIndex; - final short[] table = getHashTable(maxIndex); + final short[] table = getHashTable(length); final int shift = 32 - (int) Math.floor(Math.log(table.length) / Math.log(2)); int nextEmit = inIndex; - if (maxIndex - inIndex >= MIN_COMPRESSIBLE_BYTES) { + if (length - inIndex >= MIN_COMPRESSIBLE_BYTES) { int nextHash = hash(in, ++inIndex, shift); outer: while (true) { int skip = 32; @@ -92,7 +91,7 @@ public class Snappy { nextIndex = inIndex + bytesBetweenHashLookups; // We need at least 4 remaining bytes to read the hash - if (nextIndex > maxIndex - 4) { + if (nextIndex > length - 4) { break outer; } @@ -109,14 +108,14 @@ public class Snappy { int insertTail; do { int base = inIndex; - int matched = 4 + findMatchingLength(in, candidate + 4, inIndex + 4, maxIndex); + int matched = 4 + findMatchingLength(in, candidate + 4, inIndex + 4, length); inIndex += matched; int offset = base - candidate; encodeCopy(out, offset, matched); in.readerIndex(in.readerIndex() + matched); insertTail = inIndex - 1; nextEmit = inIndex; - if (inIndex >= maxIndex - 4) { + if (inIndex >= length - 4) { break outer; } @@ -134,8 +133,8 @@ public class Snappy { } // If there are any remaining characters, write them out as a literal - if (nextEmit < maxIndex) { - encodeLiteral(in, out, maxIndex - nextEmit); + if (nextEmit < length) { + encodeLiteral(in, out, length - nextEmit); } } diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java index 104c056add..c40134df7c 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteInput.java @@ -27,7 +27,7 @@ class ChannelBufferByteInput implements ByteInput { private final ByteBuf buffer; - public ChannelBufferByteInput(ByteBuf buffer) { + ChannelBufferByteInput(ByteBuf buffer) { this.buffer = buffer; } diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteOutput.java b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteOutput.java index 7610955da5..416102f282 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteOutput.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/ChannelBufferByteOutput.java @@ -32,7 +32,7 @@ class ChannelBufferByteOutput implements ByteOutput { /** * Create a new instance which use the given {@link ByteBuf} */ - public ChannelBufferByteOutput(ByteBuf buffer) { + ChannelBufferByteOutput(ByteBuf buffer) { this.buffer = buffer; } diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java b/codec/src/main/java/io/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java index 998881e615..5e15cd1b4b 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/CompatibleMarshallingDecoder.java @@ -20,13 +20,12 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; import io.netty.handler.codec.TooLongFrameException; +import org.jboss.marshalling.ByteInput; +import org.jboss.marshalling.Unmarshaller; import java.io.ObjectStreamConstants; import java.util.List; -import org.jboss.marshalling.ByteInput; -import org.jboss.marshalling.Unmarshaller; - /** * {@link ReplayingDecoder} which use an {@link Unmarshaller} to read the Object out of the {@link ByteBuf}. * @@ -73,7 +72,7 @@ public class CompatibleMarshallingDecoder extends ReplayingDecoder { Object obj = unmarshaller.readObject(); unmarshaller.finish(); out.add(obj); - } catch (LimitingByteInput.TooBigObjectException e) { + } catch (LimitingByteInput.TooBigObjectException ignored) { discardingTooLongFrame = true; throw new TooLongFrameException(); } finally { diff --git a/codec/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java b/codec/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java index 47ae2bcf79..66b4ad6d87 100644 --- a/codec/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java +++ b/codec/src/main/java/io/netty/handler/codec/marshalling/LimitingByteInput.java @@ -32,7 +32,7 @@ class LimitingByteInput implements ByteInput { private final long limit; private long read; - public LimitingByteInput(ByteInput input, long limit) { + LimitingByteInput(ByteInput input, long limit) { if (limit <= 0) { throw new IllegalArgumentException("The limit MUST be > 0"); } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/ClassLoaderClassResolver.java b/codec/src/main/java/io/netty/handler/codec/serialization/ClassLoaderClassResolver.java index 89f9c283cd..b6fbeb783c 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/ClassLoaderClassResolver.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/ClassLoaderClassResolver.java @@ -27,7 +27,7 @@ class ClassLoaderClassResolver implements ClassResolver { public Class resolve(String className) throws ClassNotFoundException { try { return classLoader.loadClass(className); - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException ignored) { return Class.forName(className, false, classLoader); } } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/CompactObjectInputStream.java b/codec/src/main/java/io/netty/handler/codec/serialization/CompactObjectInputStream.java index f6e98b12cc..b80635783a 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/CompactObjectInputStream.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/CompactObjectInputStream.java @@ -65,7 +65,7 @@ class CompactObjectInputStream extends ObjectInputStream { Class clazz; try { clazz = classResolver.resolve(desc.getName()); - } catch (ClassNotFoundException ex) { + } catch (ClassNotFoundException ignored) { clazz = super.resolveClass(desc); } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java b/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java index aa5154acc2..dcc8fe5af7 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/SoftReferenceMap.java @@ -21,7 +21,7 @@ import java.util.Map; final class SoftReferenceMap extends ReferenceMap { - public SoftReferenceMap(Map> delegate) { + SoftReferenceMap(Map> delegate) { super(delegate); } diff --git a/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java b/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java index 94ecc17ed8..00e720fbcc 100644 --- a/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java +++ b/codec/src/main/java/io/netty/handler/codec/serialization/WeakReferenceMap.java @@ -21,7 +21,7 @@ import java.util.Map; final class WeakReferenceMap extends ReferenceMap { - public WeakReferenceMap(Map> delegate) { + WeakReferenceMap(Map> delegate) { super(delegate); } diff --git a/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayDecoderTest.java b/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayDecoderTest.java index acec3cbf41..3985728e05 100644 --- a/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayDecoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayDecoderTest.java @@ -26,9 +26,6 @@ import static io.netty.buffer.Unpooled.*; import static org.hamcrest.core.Is.*; import static org.junit.Assert.*; -/** - */ -@SuppressWarnings("ZeroLengthArrayAllocation") public class ByteArrayDecoderTest { private EmbeddedChannel ch; diff --git a/codec/src/test/java/io/netty/handler/codec/compression/JdkZlibTest.java b/codec/src/test/java/io/netty/handler/codec/compression/JdkZlibTest.java index b366d73b10..23f178d924 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/JdkZlibTest.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/JdkZlibTest.java @@ -31,6 +31,7 @@ public class JdkZlibTest extends ZlibTest { } @Test(expected = DecompressionException.class) + @Override public void testZLIB_OR_NONE3() throws Exception { super.testZLIB_OR_NONE3(); } diff --git a/codec/src/test/java/io/netty/handler/codec/compression/ZlibCrossTest2.java b/codec/src/test/java/io/netty/handler/codec/compression/ZlibCrossTest2.java index 9b5fec88b0..8717019ed9 100644 --- a/codec/src/test/java/io/netty/handler/codec/compression/ZlibCrossTest2.java +++ b/codec/src/test/java/io/netty/handler/codec/compression/ZlibCrossTest2.java @@ -30,6 +30,7 @@ public class ZlibCrossTest2 extends ZlibTest { } @Test(expected = DecompressionException.class) + @Override public void testZLIB_OR_NONE3() throws Exception { super.testZLIB_OR_NONE3(); } diff --git a/common/src/main/java/io/netty/util/AbstractReferenceCounted.java b/common/src/main/java/io/netty/util/AbstractReferenceCounted.java index 06334af96e..20bacafa7e 100644 --- a/common/src/main/java/io/netty/util/AbstractReferenceCounted.java +++ b/common/src/main/java/io/netty/util/AbstractReferenceCounted.java @@ -35,7 +35,6 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted { refCntUpdater = updater; } - @SuppressWarnings("FieldMayBeFinal") private volatile int refCnt = 1; @Override diff --git a/common/src/main/java/io/netty/util/DefaultAttributeMap.java b/common/src/main/java/io/netty/util/DefaultAttributeMap.java index ebdbe105ae..78ecdd12b0 100644 --- a/common/src/main/java/io/netty/util/DefaultAttributeMap.java +++ b/common/src/main/java/io/netty/util/DefaultAttributeMap.java @@ -48,7 +48,7 @@ public class DefaultAttributeMap implements AttributeMap { @SuppressWarnings("UnusedDeclaration") private volatile AtomicReferenceArray> attributes; - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("unchecked") @Override public Attribute attr(AttributeKey key) { if (key == null) { diff --git a/common/src/main/java/io/netty/util/HashedWheelTimer.java b/common/src/main/java/io/netty/util/HashedWheelTimer.java index cc1d71695e..eaec8bdc25 100644 --- a/common/src/main/java/io/netty/util/HashedWheelTimer.java +++ b/common/src/main/java/io/netty/util/HashedWheelTimer.java @@ -222,7 +222,6 @@ public class HashedWheelTimer implements Timer { leak = leakDetector.open(this); } - @SuppressWarnings("unchecked") private static HashedWheelBucket[] createWheel(int ticksPerWheel) { if (ticksPerWheel <= 0) { throw new IllegalArgumentException( @@ -306,7 +305,7 @@ public class HashedWheelTimer implements Timer { workerThread.interrupt(); try { workerThread.join(100); - } catch (InterruptedException e) { + } catch (InterruptedException ignored) { interrupted = true; } } @@ -397,8 +396,7 @@ public class HashedWheelTimer implements Timer { continue; } long calculated = timeout.deadline / tickDuration; - long remainingRounds = (calculated - tick) / wheel.length; - timeout.remainingRounds = remainingRounds; + timeout.remainingRounds = (calculated - tick) / wheel.length; final long ticks = Math.max(calculated, tick); // Ensure we don't schedule for past. int stopIndex = (int) (ticks & mask); @@ -439,7 +437,7 @@ public class HashedWheelTimer implements Timer { try { Thread.sleep(sleepTimeMs); - } catch (InterruptedException e) { + } catch (InterruptedException ignored) { if (WORKER_STATE_UPDATER.get(HashedWheelTimer.this) == WORKER_STATE_SHUTDOWN) { return Long.MIN_VALUE; } diff --git a/common/src/main/java/io/netty/util/Recycler.java b/common/src/main/java/io/netty/util/Recycler.java index 5ddbe5c3fe..a1a4c6ceda 100644 --- a/common/src/main/java/io/netty/util/Recycler.java +++ b/common/src/main/java/io/netty/util/Recycler.java @@ -164,7 +164,7 @@ public abstract class Recycler { private final WeakReference owner; private final int id = ID_GENERATOR.getAndIncrement(); - public WeakOrderQueue(Stack stack, Thread thread) { + WeakOrderQueue(Stack stack, Thread thread) { head = tail = new Link(); owner = new WeakReference(thread); synchronized (stack) { @@ -194,7 +194,7 @@ public abstract class Recycler { } // transfer as many items as we can from this queue to the stack, returning true if any were transferred - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") boolean transfer(Stack to) { Link head = this.head; diff --git a/common/src/main/java/io/netty/util/Version.java b/common/src/main/java/io/netty/util/Version.java index 22941a0dd6..2d5637d0ac 100644 --- a/common/src/main/java/io/netty/util/Version.java +++ b/common/src/main/java/io/netty/util/Version.java @@ -132,7 +132,7 @@ public final class Version { private static long parseIso8601(String value) { try { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(value).getTime(); - } catch (ParseException e) { + } catch (ParseException ignored) { return 0; } } diff --git a/common/src/main/java/io/netty/util/collection/IntObjectHashMap.java b/common/src/main/java/io/netty/util/collection/IntObjectHashMap.java index d01676094c..14ec48a1fe 100644 --- a/common/src/main/java/io/netty/util/collection/IntObjectHashMap.java +++ b/common/src/main/java/io/netty/util/collection/IntObjectHashMap.java @@ -47,7 +47,7 @@ public class IntObjectHashMap implements IntObjectMap, Iterable implements IntObjectMap, Iterable implements IntObjectMap, Iterable implements IntObjectMap, Iterable= 0) { V next = values[i]; - if (value == next || (value != null && value.equals(next))) { + if (value == next || value != null && value.equals(next)) { return true; } } @@ -265,7 +268,7 @@ public class IntObjectHashMap implements IntObjectMap, Iterable implements IntObjectMap, Iterable implements IntObjectMap, Iterable maxSize) { // Need to grow the arrays. - // TODO: consider using the next prime greater than capacity * 2. - rehash(capacity() * 2); + rehash(adjustCapacity(capacity() * 2)); } else if (available == 0) { // Open addressing requires that we have at least 1 slot available. Need to refresh // the arrays to clear any removed elements. @@ -346,7 +348,15 @@ public class IntObjectHashMap implements IntObjectMap, Iterable * TODO: consider performing re-compaction. @@ -385,7 +395,7 @@ public class IntObjectHashMap implements IntObjectMap, Iterable> first, GenericFutureListener> second) { listeners = new GenericFutureListener[2]; listeners[0] = first; diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index 9e0eb30ab2..a65671a22d 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -147,7 +147,6 @@ public class DefaultPromise extends AbstractFuture implements Promise { if (listeners instanceof DefaultFutureListeners) { ((DefaultFutureListeners) listeners).add(listener); } else { - @SuppressWarnings("unchecked") final GenericFutureListener> firstListener = (GenericFutureListener>) listeners; listeners = new DefaultFutureListeners(firstListener, listener); @@ -559,7 +558,6 @@ public class DefaultPromise extends AbstractFuture implements Promise { if (listeners instanceof DefaultFutureListeners) { notifyListeners0(this, (DefaultFutureListeners) listeners); } else { - @SuppressWarnings("unchecked") final GenericFutureListener> l = (GenericFutureListener>) listeners; notifyListener0(this, l); @@ -582,7 +580,6 @@ public class DefaultPromise extends AbstractFuture implements Promise { } }); } else { - @SuppressWarnings("unchecked") final GenericFutureListener> l = (GenericFutureListener>) listeners; execute(executor, new Runnable() { @@ -729,7 +726,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("unchecked") void notifyProgressiveListeners(final long progress, final long total) { final Object listeners = progressiveListeners(); if (listeners == null) { @@ -794,7 +791,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { private static final class CauseHolder { final Throwable cause; - private CauseHolder(Throwable cause) { + CauseHolder(Throwable cause) { this.cause = cause; } } diff --git a/common/src/main/java/io/netty/util/concurrent/ScheduledFuture.java b/common/src/main/java/io/netty/util/concurrent/ScheduledFuture.java index 6d62d0d21b..2716532e1a 100644 --- a/common/src/main/java/io/netty/util/concurrent/ScheduledFuture.java +++ b/common/src/main/java/io/netty/util/concurrent/ScheduledFuture.java @@ -18,5 +18,6 @@ package io.netty.util.concurrent; /** * The result of an scheduled asynchronous operation. */ +@SuppressWarnings("ClassNameSameAsAncestorName") public interface ScheduledFuture extends Future, java.util.concurrent.ScheduledFuture { } diff --git a/common/src/main/java/io/netty/util/internal/EmptyArrays.java b/common/src/main/java/io/netty/util/internal/EmptyArrays.java index 308710c3b0..52c9f24bee 100644 --- a/common/src/main/java/io/netty/util/internal/EmptyArrays.java +++ b/common/src/main/java/io/netty/util/internal/EmptyArrays.java @@ -30,6 +30,7 @@ public final class EmptyArrays { public static final short[] EMPTY_SHORTS = new short[0]; public static final long[] EMPTY_LONGS = new long[0]; public static final Object[] EMPTY_OBJECTS = new Object[0]; + public static final Class[] EMPTY_CLASSES = new Class[0]; public static final String[] EMPTY_STRINGS = new String[0]; public static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0]; public static final ByteBuffer[] EMPTY_BYTE_BUFFERS = new ByteBuffer[0]; diff --git a/common/src/main/java/io/netty/util/internal/PlatformDependent0.java b/common/src/main/java/io/netty/util/internal/PlatformDependent0.java index 1e2504d92a..f58be03d66 100644 --- a/common/src/main/java/io/netty/util/internal/PlatformDependent0.java +++ b/common/src/main/java/io/netty/util/internal/PlatformDependent0.java @@ -87,8 +87,7 @@ final class PlatformDependent0 { // http://www.mail-archive.com/jdk6-dev@openjdk.java.net/msg00698.html try { unsafe.getClass().getDeclaredMethod( - "copyMemory", - new Class[] { Object.class, long.class, Object.class, long.class, long.class }); + "copyMemory", Object.class, long.class, Object.class, long.class, long.class); logger.debug("sun.misc.Unsafe.copyMemory: available"); } catch (NoSuchMethodError t) { diff --git a/common/src/main/java/io/netty/util/internal/SystemPropertyUtil.java b/common/src/main/java/io/netty/util/internal/SystemPropertyUtil.java index 4801ad28d3..16cd1faa37 100644 --- a/common/src/main/java/io/netty/util/internal/SystemPropertyUtil.java +++ b/common/src/main/java/io/netty/util/internal/SystemPropertyUtil.java @@ -29,12 +29,12 @@ import java.util.regex.Pattern; */ public final class SystemPropertyUtil { - @SuppressWarnings("all") private static boolean initializedLogger; private static final InternalLogger logger; private static boolean loggedException; static { + initializedLogger = false; logger = InternalLoggerFactory.getInstance(SystemPropertyUtil.class); initializedLogger = true; } diff --git a/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java b/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java index a80e94c9c8..67262aa288 100644 --- a/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java +++ b/common/src/main/java/io/netty/util/internal/logging/InternalLoggerFactory.java @@ -35,6 +35,14 @@ public abstract class InternalLoggerFactory { static { final String name = InternalLoggerFactory.class.getName(); + InternalLoggerFactory f; + f = newDefaultFactory(name); + + defaultFactory = f; + } + + @SuppressWarnings("UnusedCatchParameter") + private static InternalLoggerFactory newDefaultFactory(String name) { InternalLoggerFactory f; try { f = new Slf4JLoggerFactory(true); @@ -49,8 +57,7 @@ public abstract class InternalLoggerFactory { f.newInstance(name).debug("Using java.util.logging as the default logging framework"); } } - - defaultFactory = f; + return f; } /** diff --git a/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java b/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java index 7f5b20f2fe..27b9130a08 100644 --- a/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/Log4JLogger.java @@ -72,7 +72,7 @@ class Log4JLogger extends AbstractInternalLogger { try { logger.isTraceEnabled(); return true; - } catch (NoSuchMethodError e) { + } catch (NoSuchMethodError ignored) { return false; } } diff --git a/common/src/main/java/io/netty/util/internal/logging/Slf4JLogger.java b/common/src/main/java/io/netty/util/internal/logging/Slf4JLogger.java index a759372100..e78727ca0f 100644 --- a/common/src/main/java/io/netty/util/internal/logging/Slf4JLogger.java +++ b/common/src/main/java/io/netty/util/internal/logging/Slf4JLogger.java @@ -52,7 +52,7 @@ class Slf4JLogger extends AbstractInternalLogger { } @Override - public void trace(String format, Object[] argArray) { + public void trace(String format, Object... argArray) { logger.trace(format, argArray); } @@ -82,7 +82,7 @@ class Slf4JLogger extends AbstractInternalLogger { } @Override - public void debug(String format, Object[] argArray) { + public void debug(String format, Object... argArray) { logger.debug(format, argArray); } @@ -112,7 +112,7 @@ class Slf4JLogger extends AbstractInternalLogger { } @Override - public void info(String format, Object[] argArray) { + public void info(String format, Object... argArray) { logger.info(format, argArray); } @@ -137,7 +137,7 @@ class Slf4JLogger extends AbstractInternalLogger { } @Override - public void warn(String format, Object[] argArray) { + public void warn(String format, Object... argArray) { logger.warn(format, argArray); } @@ -172,7 +172,7 @@ class Slf4JLogger extends AbstractInternalLogger { } @Override - public void error(String format, Object[] argArray) { + public void error(String format, Object... argArray) { logger.error(format, argArray); } diff --git a/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java b/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java index ecef300d36..e31e55cb98 100644 --- a/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java +++ b/common/src/main/java/io/netty/util/internal/logging/Slf4JLoggerFactory.java @@ -54,7 +54,7 @@ public class Slf4JLoggerFactory extends InternalLoggerFactory { if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) { throw new NoClassDefFoundError(buf.toString()); } else { - err.print(buf.toString()); + err.print(buf); err.flush(); } } finally { diff --git a/common/src/test/java/io/netty/util/DefaultAttributeMapTest.java b/common/src/test/java/io/netty/util/DefaultAttributeMapTest.java index ce49bfbc42..1bdb8b019a 100644 --- a/common/src/test/java/io/netty/util/DefaultAttributeMapTest.java +++ b/common/src/test/java/io/netty/util/DefaultAttributeMapTest.java @@ -42,10 +42,10 @@ public class DefaultAttributeMapTest { assertSame(one, map.attr(key)); one.setIfAbsent("Whoohoo"); - assertSame(one.get(), "Whoohoo"); + assertSame("Whoohoo", one.get()); one.setIfAbsent("What"); - assertNotSame(one.get(), "What"); + assertNotSame("What", one.get()); one.remove(); assertNull(one.get()); @@ -62,7 +62,7 @@ public class DefaultAttributeMapTest { assertEquals(one.get(), Integer.valueOf(3653)); one.setIfAbsent(1); - assertNotSame(one.get(), 1); + assertNotSame(1, one.get()); one.remove(); assertNull(one.get()); diff --git a/common/src/test/java/io/netty/util/RecyclerTest.java b/common/src/test/java/io/netty/util/RecyclerTest.java index 1e10522adb..5212e9b4df 100644 --- a/common/src/test/java/io/netty/util/RecyclerTest.java +++ b/common/src/test/java/io/netty/util/RecyclerTest.java @@ -40,14 +40,14 @@ public class RecyclerTest { private static final Recycler RECYCLER = new Recycler() { @Override - protected RecyclableObject newObject(Handle handle) { + protected RecyclableObject newObject(Handle handle) { return new RecyclableObject(handle); } }; - private final Recycler.Handle handle; + private final Recycler.Handle handle; - private RecyclableObject(Recycler.Handle handle) { + private RecyclableObject(Recycler.Handle handle) { this.handle = handle; } diff --git a/common/src/test/java/io/netty/util/collection/IntObjectHashMapTest.java b/common/src/test/java/io/netty/util/collection/IntObjectHashMapTest.java index 207817236c..7f50134ef8 100644 --- a/common/src/test/java/io/netty/util/collection/IntObjectHashMapTest.java +++ b/common/src/test/java/io/netty/util/collection/IntObjectHashMapTest.java @@ -14,17 +14,13 @@ */ package io.netty.util.collection; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.Test; import java.util.HashSet; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import static org.junit.Assert.*; /** * Tests for {@link IntObjectHashMap}. @@ -34,7 +30,7 @@ public class IntObjectHashMapTest { private static class Value { private final String name; - public Value(String name) { + Value(String name) { this.name = name; } @@ -42,7 +38,7 @@ public class IntObjectHashMapTest { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + (name == null ? 0 : name.hashCode()); return result; } diff --git a/common/src/test/java/io/netty/util/internal/AppendableCharSequenceTest.java b/common/src/test/java/io/netty/util/internal/AppendableCharSequenceTest.java index 81c5560bc3..2d7bab4ec8 100644 --- a/common/src/test/java/io/netty/util/internal/AppendableCharSequenceTest.java +++ b/common/src/test/java/io/netty/util/internal/AppendableCharSequenceTest.java @@ -61,7 +61,7 @@ public class AppendableCharSequenceTest { public void testSubSequence() { AppendableCharSequence master = new AppendableCharSequence(26); master.append("abcdefghijlkmonpqrstuvwxyz"); - assertEquals(master.subSequence(0, 10).toString(), "abcdefghij"); + assertEquals("abcdefghij", master.subSequence(0, 10).toString()); } private static void testSimpleAppend0(AppendableCharSequence seq) { diff --git a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java index 47d8fb4398..e427b6f581 100644 --- a/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java +++ b/common/src/test/java/io/netty/util/internal/TypeParameterMatcherTest.java @@ -83,17 +83,14 @@ public class TypeParameterMatcherTest { public static class TypeQ extends TypeZ { } - @SuppressWarnings("ClassMayBeInterface") public static class A { } public static class AA extends A { } public static class AAA extends AA { } - @SuppressWarnings("ClassMayBeInterface") public static class B { } public static class BB extends B { } public static class BBB extends BB { } - @SuppressWarnings("ClassMayBeInterface") public static class C { } public static class CC extends C { } @@ -104,7 +101,6 @@ public class TypeParameterMatcherTest { assertTrue(m.match(new T())); } - @SuppressWarnings("ClassMayBeInterface") private static class T { } private static class U { E a; } diff --git a/example/src/main/java/io/netty/example/echo/EchoClient.java b/example/src/main/java/io/netty/example/echo/EchoClient.java index 302e8dae3e..f0023e8975 100644 --- a/example/src/main/java/io/netty/example/echo/EchoClient.java +++ b/example/src/main/java/io/netty/example/echo/EchoClient.java @@ -24,8 +24,6 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.logging.LogLevel; -import io.netty.handler.logging.LoggingHandler; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.util.InsecureTrustManagerFactory; diff --git a/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java b/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java index 33bd3b3f08..1a334d8ff8 100644 --- a/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java +++ b/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java @@ -17,7 +17,7 @@ package io.netty.example.http.cors; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; @@ -27,10 +27,10 @@ import io.netty.handler.codec.http.HttpVersion; * A simple handler which will simple return a successful Http * response for any request. */ -public class OkResponseHandler extends SimpleChannelInboundHandler { +public class OkResponseHandler extends ChannelInboundHandlerAdapter { @Override - public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { final FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); response.headers().set("custom-response-header", "Some value"); ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java index 312ffc9952..3acb697086 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServer.java @@ -26,7 +26,7 @@ import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslProvider; import io.netty.handler.ssl.util.SelfSignedCertificate; -public class HttpStaticFileServer { +public final class HttpStaticFileServer { static final boolean SSL = System.getProperty("ssl") != null; static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8443" : "8080")); diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java index 3b2aab102a..32443d6eb8 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java @@ -53,7 +53,6 @@ import java.util.TimeZone; import java.util.regex.Pattern; import static io.netty.handler.codec.http.HttpHeaders.Names.*; -import static io.netty.handler.codec.http.HttpHeaders.*; import static io.netty.handler.codec.http.HttpMethod.*; import static io.netty.handler.codec.http.HttpResponseStatus.*; import static io.netty.handler.codec.http.HttpVersion.*; @@ -175,10 +174,10 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler { @Override - public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { + public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java index 28b82bd6cc..3628d3c2ef 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServer.java @@ -29,7 +29,7 @@ import io.netty.handler.ssl.util.SelfSignedCertificate; * An HTTP server that sends back the content of the received HTTP request * in a pretty plaintext form. */ -public class HttpSnoopServer { +public final class HttpSnoopServer { static final boolean SSL = System.getProperty("ssl") != null; static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8443" : "8080")); diff --git a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java index 8a0d43b1f8..8e20875ca1 100644 --- a/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java +++ b/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java @@ -40,7 +40,6 @@ import java.util.Map.Entry; import java.util.Set; import static io.netty.handler.codec.http.HttpHeaders.Names.*; -import static io.netty.handler.codec.http.HttpHeaders.*; import static io.netty.handler.codec.http.HttpResponseStatus.*; import static io.netty.handler.codec.http.HttpVersion.*; @@ -60,7 +59,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler if (msg instanceof HttpRequest) { HttpRequest request = this.request = (HttpRequest) msg; - if (is100ContinueExpected(request)) { + if (HttpHeaders.is100ContinueExpected(request)) { send100Continue(ctx); } @@ -69,7 +68,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler buf.append("===================================\r\n"); buf.append("VERSION: ").append(request.protocolVersion()).append("\r\n"); - buf.append("HOSTNAME: ").append(getHost(request, "unknown")).append("\r\n"); + buf.append("HOSTNAME: ").append(HttpHeaders.getHost(request, "unknown")).append("\r\n"); buf.append("REQUEST_URI: ").append(request.uri()).append("\r\n\r\n"); HttpHeaders headers = request.headers(); @@ -145,7 +144,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler private boolean writeResponse(HttpObject currentObj, ChannelHandlerContext ctx) { // Decide whether to close the connection or not. - boolean keepAlive = isKeepAlive(request); + boolean keepAlive = HttpHeaders.isKeepAlive(request); // Build the response object. FullHttpResponse response = new DefaultFullHttpResponse( HTTP_1_1, currentObj.decoderResult().isSuccess()? OK : BAD_REQUEST, diff --git a/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java b/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java index dfcff09ead..37377cf40b 100644 --- a/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java +++ b/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java @@ -32,7 +32,7 @@ public class HttpUploadClientHandler extends SimpleChannelInboundHandler private WebSocketServerHandshaker handshaker; @Override - public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead0(ChannelHandlerContext ctx, Object msg) { if (msg instanceof FullHttpRequest) { handleHttpRequest(ctx, (FullHttpRequest) msg); } else if (msg instanceof WebSocketFrame) { @@ -81,7 +81,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, OK, content); res.headers().set(CONTENT_TYPE, "text/html; charset=UTF-8"); - setContentLength(res, content.readableBytes()); + HttpHeaders.setContentLength(res, content.readableBytes()); sendHttpResponse(ctx, req, res); return; @@ -132,12 +132,12 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler ByteBuf buf = Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8); res.content().writeBytes(buf); buf.release(); - setContentLength(res, res.content().readableBytes()); + HttpHeaders.setContentLength(res, res.content().readableBytes()); } // Send the response and close the connection if necessary. ChannelFuture f = ctx.channel().writeAndFlush(res); - if (!isKeepAlive(req) || res.status().code() != 200) { + if (!HttpHeaders.isKeepAlive(req) || res.status().code() != 200) { f.addListener(ChannelFutureListener.CLOSE); } } diff --git a/example/src/main/java/io/netty/example/spdy/client/SpdyClient.java b/example/src/main/java/io/netty/example/spdy/client/SpdyClient.java index f425074879..bccbe9e560 100644 --- a/example/src/main/java/io/netty/example/spdy/client/SpdyClient.java +++ b/example/src/main/java/io/netty/example/spdy/client/SpdyClient.java @@ -45,7 +45,7 @@ import java.util.Arrays; * ./run-example.sh spdy-client * */ -public class SpdyClient { +public final class SpdyClient { static final boolean SSL = System.getProperty("ssl") != null; static final String HOST = System.getProperty("host", "127.0.0.1"); diff --git a/example/src/main/java/io/netty/example/telnet/TelnetServer.java b/example/src/main/java/io/netty/example/telnet/TelnetServer.java index 936905658c..751add8794 100644 --- a/example/src/main/java/io/netty/example/telnet/TelnetServer.java +++ b/example/src/main/java/io/netty/example/telnet/TelnetServer.java @@ -27,7 +27,7 @@ import io.netty.handler.ssl.util.SelfSignedCertificate; /** * Simplistic telnet server. */ -public class TelnetServer { +public final class TelnetServer { static final boolean SSL = System.getProperty("ssl") != null; static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8992" : "8023")); diff --git a/example/src/main/java/io/netty/example/udt/echo/rendezvousBytes/ByteEchoPeerBase.java b/example/src/main/java/io/netty/example/udt/echo/rendezvousBytes/ByteEchoPeerBase.java index 0d9b39b12c..55d857d9b5 100644 --- a/example/src/main/java/io/netty/example/udt/echo/rendezvousBytes/ByteEchoPeerBase.java +++ b/example/src/main/java/io/netty/example/udt/echo/rendezvousBytes/ByteEchoPeerBase.java @@ -40,8 +40,8 @@ import java.util.concurrent.ThreadFactory; public class ByteEchoPeerBase { protected final int messageSize; - protected SocketAddress myAddress; - protected SocketAddress peerAddress; + protected final SocketAddress myAddress; + protected final SocketAddress peerAddress; public ByteEchoPeerBase(int messageSize, SocketAddress myAddress, SocketAddress peerAddress) { this.messageSize = messageSize; diff --git a/example/src/main/resources/cors/cors.html b/example/src/main/resources/cors/cors.html index ad5a75b699..f443a641dd 100644 --- a/example/src/main/resources/cors/cors.html +++ b/example/src/main/resources/cors/cors.html @@ -10,7 +10,7 @@