diff --git a/common/src/main/java/io/netty/util/DefaultAttributeMap.java b/common/src/main/java/io/netty/util/DefaultAttributeMap.java index dcbebf54bf..648c2994b9 100644 --- a/common/src/main/java/io/netty/util/DefaultAttributeMap.java +++ b/common/src/main/java/io/netty/util/DefaultAttributeMap.java @@ -32,6 +32,7 @@ public class DefaultAttributeMap implements AttributeMap { map = this.map = new IdentityHashMap, Attribute>(2); } + @SuppressWarnings("unchecked") Attribute attr = (Attribute) map.get(key); if (attr == null) { attr = new DefaultAttribute(); diff --git a/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java b/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java index 8cd5c05520..86d51c6cc0 100644 --- a/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java @@ -153,7 +153,9 @@ public abstract class AbstractBootstrap> { attrs.put(key, value); } - return (B) this; + @SuppressWarnings("unchecked") + B b = (B) this; + return b; } /** diff --git a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java index 84e5d4a7e2..232f642267 100644 --- a/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java +++ b/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java @@ -173,7 +173,9 @@ public class ServerBootstrap extends AbstractBootstrap { } for (Entry, Object> e: attrs().entrySet()) { - channel.attr((AttributeKey) e.getKey()).set(e.getValue()); + @SuppressWarnings("unchecked") + AttributeKey key = (AttributeKey) e.getKey(); + channel.attr(key).set(e.getValue()); } ChannelPipeline p = future.channel().pipeline(); diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index 3b4708ec18..89ebdc5e88 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -278,8 +278,9 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha } @Override - public MessageBuf outboundMessageBuffer() { - return pipeline.outboundMessageBuffer(); + @SuppressWarnings("unchecked") + public MessageBuf outboundMessageBuffer() { + return (MessageBuf) pipeline.outboundMessageBuffer(); } @Override diff --git a/transport/src/main/java/io/netty/channel/AbstractServerChannel.java b/transport/src/main/java/io/netty/channel/AbstractServerChannel.java index 03d42ead89..146b3842f3 100755 --- a/transport/src/main/java/io/netty/channel/AbstractServerChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractServerChannel.java @@ -49,7 +49,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S } @Override - public MessageBuf outboundMessageBuffer() { + public MessageBuf outboundMessageBuffer() { throw new NoSuchBufferException(String.format( "%s does not have an outbound buffer.", ServerChannel.class.getSimpleName())); } diff --git a/transport/src/main/java/io/netty/channel/ChannelPipeline.java b/transport/src/main/java/io/netty/channel/ChannelPipeline.java index f33595dce0..adbb5f2101 100644 --- a/transport/src/main/java/io/netty/channel/ChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/ChannelPipeline.java @@ -205,9 +205,9 @@ import java.util.NoSuchElementException; */ public interface ChannelPipeline extends ChannelInboundInvoker, ChannelOutboundInvoker { - MessageBuf inboundMessageBuffer(); + MessageBuf inboundMessageBuffer(); ByteBuf inboundByteBuffer(); - MessageBuf outboundMessageBuffer(); + MessageBuf outboundMessageBuffer(); ByteBuf outboundByteBuffer(); /** diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 9c2519a87d..d5286af6e6 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -355,7 +355,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } else if (buf instanceof MessageBuf) { outByteBuf = null; outByteBridge = null; - outMsgBuf = (MessageBuf) buf; + @SuppressWarnings("unchecked") + MessageBuf msgBuf = (MessageBuf) buf; + outMsgBuf = msgBuf; outMsgBridge = new AtomicReference(); } else { throw new Error(); diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java index 42409f6a97..9ee977d985 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java @@ -844,8 +844,9 @@ public class DefaultChannelPipeline implements ChannelPipeline { } @Override - public MessageBuf inboundMessageBuffer() { - return head.nextInboundMessageBuffer(); + @SuppressWarnings("unchecked") + public MessageBuf inboundMessageBuffer() { + return (MessageBuf) head.nextInboundMessageBuffer(); } @Override @@ -854,8 +855,9 @@ public class DefaultChannelPipeline implements ChannelPipeline { } @Override - public MessageBuf outboundMessageBuffer() { - return nextOutboundMessageBuffer(tail); + @SuppressWarnings("unchecked") + public MessageBuf outboundMessageBuffer() { + return (MessageBuf) nextOutboundMessageBuffer(tail); } @Override diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java index aa634a8857..4da88f787b 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioEventLoop.java @@ -306,7 +306,9 @@ public final class NioEventLoop extends SingleThreadEventLoop { if (a instanceof AbstractNioChannel) { processSelectedKey(k, (AbstractNioChannel) a); } else { - processSelectedKey(k, (NioTask) a); + @SuppressWarnings("unchecked") + NioTask task = (NioTask) a; + processSelectedKey(k, task); } if (cleanedCancelledKeys) { @@ -376,7 +378,9 @@ public final class NioEventLoop extends SingleThreadEventLoop { channels.add((Channel) a); } else { k.cancel(); - invokeChannelUnregistered((NioTask) a, k); + @SuppressWarnings("unchecked") + NioTask task = (NioTask) a; + invokeChannelUnregistered(task, k); } }