Fix all Xlint:unchecked warnings

This commit is contained in:
Trustin Lee 2012-11-30 22:49:51 +09:00
parent b33df8399e
commit 818a7b42a3
9 changed files with 28 additions and 14 deletions

View File

@ -32,6 +32,7 @@ public class DefaultAttributeMap implements AttributeMap {
map = this.map = new IdentityHashMap<AttributeKey<?>, Attribute<?>>(2); map = this.map = new IdentityHashMap<AttributeKey<?>, Attribute<?>>(2);
} }
@SuppressWarnings("unchecked")
Attribute<T> attr = (Attribute<T>) map.get(key); Attribute<T> attr = (Attribute<T>) map.get(key);
if (attr == null) { if (attr == null) {
attr = new DefaultAttribute<T>(); attr = new DefaultAttribute<T>();

View File

@ -153,7 +153,9 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<?>> {
attrs.put(key, value); attrs.put(key, value);
} }
return (B) this; @SuppressWarnings("unchecked")
B b = (B) this;
return b;
} }
/** /**

View File

@ -173,7 +173,9 @@ public class ServerBootstrap extends AbstractBootstrap<ServerBootstrap> {
} }
for (Entry<AttributeKey<?>, Object> e: attrs().entrySet()) { for (Entry<AttributeKey<?>, Object> e: attrs().entrySet()) {
channel.attr((AttributeKey<Object>) e.getKey()).set(e.getValue()); @SuppressWarnings("unchecked")
AttributeKey<Object> key = (AttributeKey<Object>) e.getKey();
channel.attr(key).set(e.getValue());
} }
ChannelPipeline p = future.channel().pipeline(); ChannelPipeline p = future.channel().pipeline();

View File

@ -278,8 +278,9 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
} }
@Override @Override
public MessageBuf<Object> outboundMessageBuffer() { @SuppressWarnings("unchecked")
return pipeline.outboundMessageBuffer(); public <T> MessageBuf<T> outboundMessageBuffer() {
return (MessageBuf<T>) pipeline.outboundMessageBuffer();
} }
@Override @Override

View File

@ -49,7 +49,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
} }
@Override @Override
public MessageBuf<Object> outboundMessageBuffer() { public <T> MessageBuf<T> outboundMessageBuffer() {
throw new NoSuchBufferException(String.format( throw new NoSuchBufferException(String.format(
"%s does not have an outbound buffer.", ServerChannel.class.getSimpleName())); "%s does not have an outbound buffer.", ServerChannel.class.getSimpleName()));
} }

View File

@ -205,9 +205,9 @@ import java.util.NoSuchElementException;
*/ */
public interface ChannelPipeline extends ChannelInboundInvoker, ChannelOutboundInvoker { public interface ChannelPipeline extends ChannelInboundInvoker, ChannelOutboundInvoker {
MessageBuf<Object> inboundMessageBuffer(); <T> MessageBuf<T> inboundMessageBuffer();
ByteBuf inboundByteBuffer(); ByteBuf inboundByteBuffer();
MessageBuf<Object> outboundMessageBuffer(); <T> MessageBuf<T> outboundMessageBuffer();
ByteBuf outboundByteBuffer(); ByteBuf outboundByteBuffer();
/** /**

View File

@ -355,7 +355,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
} else if (buf instanceof MessageBuf) { } else if (buf instanceof MessageBuf) {
outByteBuf = null; outByteBuf = null;
outByteBridge = null; outByteBridge = null;
outMsgBuf = (MessageBuf<Object>) buf; @SuppressWarnings("unchecked")
MessageBuf<Object> msgBuf = (MessageBuf<Object>) buf;
outMsgBuf = msgBuf;
outMsgBridge = new AtomicReference<MessageBridge>(); outMsgBridge = new AtomicReference<MessageBridge>();
} else { } else {
throw new Error(); throw new Error();

View File

@ -844,8 +844,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
} }
@Override @Override
public MessageBuf<Object> inboundMessageBuffer() { @SuppressWarnings("unchecked")
return head.nextInboundMessageBuffer(); public <T> MessageBuf<T> inboundMessageBuffer() {
return (MessageBuf<T>) head.nextInboundMessageBuffer();
} }
@Override @Override
@ -854,8 +855,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
} }
@Override @Override
public MessageBuf<Object> outboundMessageBuffer() { @SuppressWarnings("unchecked")
return nextOutboundMessageBuffer(tail); public <T> MessageBuf<T> outboundMessageBuffer() {
return (MessageBuf<T>) nextOutboundMessageBuffer(tail);
} }
@Override @Override

View File

@ -306,7 +306,9 @@ public final class NioEventLoop extends SingleThreadEventLoop {
if (a instanceof AbstractNioChannel) { if (a instanceof AbstractNioChannel) {
processSelectedKey(k, (AbstractNioChannel) a); processSelectedKey(k, (AbstractNioChannel) a);
} else { } else {
processSelectedKey(k, (NioTask<SelectableChannel>) a); @SuppressWarnings("unchecked")
NioTask<SelectableChannel> task = (NioTask<SelectableChannel>) a;
processSelectedKey(k, task);
} }
if (cleanedCancelledKeys) { if (cleanedCancelledKeys) {
@ -376,7 +378,9 @@ public final class NioEventLoop extends SingleThreadEventLoop {
channels.add((Channel) a); channels.add((Channel) a);
} else { } else {
k.cancel(); k.cancel();
invokeChannelUnregistered((NioTask<SelectableChannel>) a, k); @SuppressWarnings("unchecked")
NioTask<SelectableChannel> task = (NioTask<SelectableChannel>) a;
invokeChannelUnregistered(task, k);
} }
} }