diff --git a/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java b/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java index 02f27d2af3..673e1b3fbd 100644 --- a/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java +++ b/src/main/java/org/jboss/netty/buffer/ChannelBuffers.java @@ -804,8 +804,7 @@ public class ChannelBuffers { } private static ChannelBuffer copiedBuffer(ByteOrder endianness, CharBuffer buffer, Charset charset) { - CharBuffer src = buffer; - ByteBuffer dst = ChannelBuffers.encodeString(src, charset); + ByteBuffer dst = ChannelBuffers.encodeString(buffer, charset); ChannelBuffer result = wrappedBuffer(endianness, dst.array()); result.writerIndex(dst.remaining()); return result; diff --git a/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java b/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java index 82f589925d..0feb943ecf 100644 --- a/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java +++ b/src/main/java/org/jboss/netty/channel/group/CombinedIterator.java @@ -59,8 +59,7 @@ final class CombinedIterator implements Iterator { @Override public E next() { try { - E e = currentIterator.next(); - return e; + return currentIterator.next(); } catch (NoSuchElementException e) { if (currentIterator == i1) { currentIterator = i2; diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelMessageUtils.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelMessageUtils.java index 54ed0812f9..736fe28df3 100644 --- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelMessageUtils.java +++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelMessageUtils.java @@ -252,9 +252,7 @@ public class HttpTunnelMessageUtils { } public static HttpResponse createTunnelCloseResponse() { - HttpResponse response = - createResponseTemplate(HttpResponseStatus.RESET_CONTENT, null); - return response; + return createResponseTemplate(HttpResponseStatus.RESET_CONTENT, null); } public static boolean isTunnelCloseResponse(HttpResponse response) { diff --git a/src/main/java/org/jboss/netty/handler/codec/http/MixedAttribute.java b/src/main/java/org/jboss/netty/handler/codec/http/MixedAttribute.java index 4bad8f9c03..8a70125c68 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/MixedAttribute.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/MixedAttribute.java @@ -143,9 +143,7 @@ public class MixedAttribute implements Attribute { if (buffer.readableBytes() > limitSize) { if (attribute instanceof MemoryAttribute) { // change to Disk - DiskAttribute diskAttribute = new DiskAttribute(attribute - .getName()); - attribute = diskAttribute; + attribute = new DiskAttribute(attribute.getName()); } } attribute.setContent(buffer); @@ -156,9 +154,7 @@ public class MixedAttribute implements Attribute { if (file.length() > limitSize) { if (attribute instanceof MemoryAttribute) { // change to Disk - DiskAttribute diskAttribute = new DiskAttribute(attribute - .getName()); - attribute = diskAttribute; + attribute = new DiskAttribute(attribute.getName()); } } attribute.setContent(file); @@ -168,9 +164,7 @@ public class MixedAttribute implements Attribute { public void setContent(InputStream inputStream) throws IOException { if (attribute instanceof MemoryAttribute) { // change to Disk even if we don't know the size - DiskAttribute diskAttribute = new DiskAttribute(attribute - .getName()); - attribute = diskAttribute; + attribute = new DiskAttribute(attribute.getName()); } attribute.setContent(inputStream); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/MixedFileUpload.java b/src/main/java/org/jboss/netty/handler/codec/http/MixedFileUpload.java index 51994ff267..8c7df5e4ed 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/MixedFileUpload.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/MixedFileUpload.java @@ -147,12 +147,11 @@ public class MixedFileUpload implements FileUpload { if (buffer.readableBytes() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { // change to Disk - DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload + fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); - fileUpload = diskFileUpload; } } fileUpload.setContent(buffer); @@ -163,12 +162,11 @@ public class MixedFileUpload implements FileUpload { if (file.length() > limitSize) { if (fileUpload instanceof MemoryFileUpload) { // change to Disk - DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload + fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); - fileUpload = diskFileUpload; } } fileUpload.setContent(file); @@ -178,12 +176,11 @@ public class MixedFileUpload implements FileUpload { public void setContent(InputStream inputStream) throws IOException { if (fileUpload instanceof MemoryFileUpload) { // change to Disk - DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload + fileUpload = new DiskFileUpload(fileUpload .getName(), fileUpload.getFilename(), fileUpload .getContentType(), fileUpload .getContentTransferEncoding(), fileUpload.getCharset(), definedSize); - fileUpload = diskFileUpload; } fileUpload.setContent(inputStream); } diff --git a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java index d40ea276ff..c362dba8d5 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/websocketx/WebSocketClientHandshaker.java @@ -204,7 +204,6 @@ public abstract class WebSocketClientHandshaker { * @return Random number */ protected int createRandomNumber(int min, int max) { - int rand = (int) (Math.random() * max + min); - return rand; + return (int) (Math.random() * max + min); } } diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/CompatibleObjectEncoder.java b/src/main/java/org/jboss/netty/handler/codec/serialization/CompatibleObjectEncoder.java index 6395898b9c..f2399281b1 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/CompatibleObjectEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/CompatibleObjectEncoder.java @@ -98,8 +98,7 @@ public class CompatibleObjectEncoder extends OneToOneEncoder { oout.writeObject(msg); oout.flush(); - ChannelBuffer encoded = buffer.readBytes(buffer.readableBytes()); - return encoded; + return buffer.readBytes(buffer.readableBytes()); } private ChannelBuffer buffer(ChannelHandlerContext ctx) throws Exception { diff --git a/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java b/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java index 1768321f1a..b2c8d12fe1 100644 --- a/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java +++ b/src/main/java/org/jboss/netty/handler/ipfilter/IpFilteringHandlerImpl.java @@ -66,8 +66,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler, { if (listener == null) return null; - ChannelFuture result = listener.refused(ctx, e, inetSocketAddress); - return result; + return listener.refused(ctx, e, inetSocketAddress); } protected ChannelFuture handleAllowedChannel(ChannelHandlerContext ctx, ChannelEvent e, @@ -75,8 +74,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler, { if (listener == null) return null; - ChannelFuture result = listener.allowed(ctx, e, inetSocketAddress); - return result; + return listener.allowed(ctx, e, inetSocketAddress); } /** diff --git a/src/main/java/org/jboss/netty/handler/traffic/AbstractTrafficShapingHandler.java b/src/main/java/org/jboss/netty/handler/traffic/AbstractTrafficShapingHandler.java index f980dcf512..f22439f2ca 100644 --- a/src/main/java/org/jboss/netty/handler/traffic/AbstractTrafficShapingHandler.java +++ b/src/main/java/org/jboss/netty/handler/traffic/AbstractTrafficShapingHandler.java @@ -385,8 +385,7 @@ public abstract class AbstractTrafficShapingHandler extends // Time is too short, so just lets continue return 0; } - long wait = bytes * 1000 / limit - interval; - return wait; + return bytes * 1000 / limit - interval; } @Override diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java b/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java index 62eedc8a50..d463eb54e8 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java @@ -519,18 +519,16 @@ final class Deflate { } private void send_bits(int value, int length) { - int len = length; - if (bi_valid > Buf_size - len) { - int val = value; + if (bi_valid > Buf_size - length) { // bi_buf |= (val << bi_valid); - bi_buf |= val << bi_valid & 0xffff; + bi_buf |= value << bi_valid & 0xffff; put_short(bi_buf); - bi_buf = (short) (val >>> Buf_size - bi_valid); - bi_valid += len - Buf_size; + bi_buf = (short) (value >>> Buf_size - bi_valid); + bi_valid += length - Buf_size; } else { // bi_buf |= (value) << bi_valid; bi_buf |= value << bi_valid & 0xffff; - bi_valid += len; + bi_valid += length; } } diff --git a/src/test/java/org/jboss/netty/channel/socket/http/HttpTunnelServerChannelSinkTest.java b/src/test/java/org/jboss/netty/channel/socket/http/HttpTunnelServerChannelSinkTest.java index 3fb7dd9e9a..7c949cf6a8 100644 --- a/src/test/java/org/jboss/netty/channel/socket/http/HttpTunnelServerChannelSinkTest.java +++ b/src/test/java/org/jboss/netty/channel/socket/http/HttpTunnelServerChannelSinkTest.java @@ -83,9 +83,8 @@ public class HttpTunnelServerChannelSinkTest { } }); - ChannelFuture virtualFuture1 = Channels.close(channel); + ChannelFuture virtualFuture = Channels.close(channel); mockContext.assertIsSatisfied(); - ChannelFuture virtualFuture = virtualFuture1; realFuture.setSuccess(); assertTrue(virtualFuture.isSuccess()); } @@ -140,8 +139,7 @@ public class HttpTunnelServerChannelSinkTest { } }); - ChannelFuture virtualFuture = Channels.bind(channel, toAddress); - return virtualFuture; + return Channels.bind(channel, toAddress); } private final class ExceptionCatcher extends SimpleChannelUpstreamHandler {