Ensure the specified future has the correct channel / Cleanup
This commit is contained in:
parent
cb718a07c8
commit
2134848111
@ -158,42 +158,42 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
|
||||
@Override
|
||||
public ChannelFuture bind(SocketAddress localAddress) {
|
||||
return pipeline().bind(localAddress, newFuture());
|
||||
return pipeline().bind(localAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture connect(SocketAddress remoteAddress) {
|
||||
return pipeline().connect(remoteAddress, newFuture());
|
||||
return pipeline().connect(remoteAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) {
|
||||
return pipeline().connect(remoteAddress, localAddress, newFuture());
|
||||
return pipeline().connect(remoteAddress, localAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture disconnect() {
|
||||
return pipeline().disconnect(newFuture());
|
||||
return pipeline().disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture close() {
|
||||
return pipeline().close(newFuture());
|
||||
return pipeline().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture deregister() {
|
||||
return pipeline().deregister(newFuture());
|
||||
return pipeline().deregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture flush() {
|
||||
return pipeline().flush(newFuture());
|
||||
return pipeline().flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelFuture write(Object message) {
|
||||
return pipeline().write(message, newFuture());
|
||||
return pipeline().write(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -706,6 +706,8 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
if (localAddress == null) {
|
||||
throw new NullPointerException("localAddress");
|
||||
}
|
||||
validateFuture(future);
|
||||
|
||||
if (ctx != null) {
|
||||
try {
|
||||
((ChannelOutboundHandler<Object>) ctx.handler()).bind(ctx, localAddress, future);
|
||||
@ -733,6 +735,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
if (remoteAddress == null) {
|
||||
throw new NullPointerException("remoteAddress");
|
||||
}
|
||||
validateFuture(future);
|
||||
|
||||
if (ctx != null) {
|
||||
try {
|
||||
@ -754,6 +757,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ChannelFuture disconnect(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||
validateFuture(future);
|
||||
if (ctx != null) {
|
||||
try {
|
||||
((ChannelOutboundHandler<Object>) ctx.handler()).disconnect(ctx, future);
|
||||
@ -774,6 +778,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ChannelFuture close(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||
validateFuture(future);
|
||||
if (ctx != null) {
|
||||
try {
|
||||
((ChannelOutboundHandler<Object>) ctx.handler()).close(ctx, future);
|
||||
@ -794,6 +799,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ChannelFuture deregister(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||
validateFuture(future);
|
||||
if (ctx != null) {
|
||||
try {
|
||||
((ChannelOutboundHandler<Object>) ctx.handler()).deregister(ctx, future);
|
||||
@ -814,6 +820,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ChannelFuture flush(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||
validateFuture(future);
|
||||
if (ctx != null) {
|
||||
try {
|
||||
((ChannelOutboundHandler<Object>) ctx.handler()).flush(ctx, future);
|
||||
@ -829,6 +836,11 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
@Override
|
||||
public ChannelFuture write(Object message, ChannelFuture future) {
|
||||
if (message == null) {
|
||||
throw new NullPointerException("message");
|
||||
}
|
||||
validateFuture(future);
|
||||
|
||||
if (message instanceof ChannelBuffer) {
|
||||
ChannelBuffer m = (ChannelBuffer) message;
|
||||
out().byteBuffer().writeBytes(m, m.readerIndex(), m.readableBytes());
|
||||
@ -838,6 +850,16 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return flush(future);
|
||||
}
|
||||
|
||||
private void validateFuture(ChannelFuture future) {
|
||||
if (future == null) {
|
||||
throw new NullPointerException("future");
|
||||
}
|
||||
if (future.channel() != channel()) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"future.channel does not match: %s (expected: %s)", future.channel(), channel()));
|
||||
}
|
||||
}
|
||||
|
||||
private DefaultChannelHandlerContext firstInboundContext() {
|
||||
return nextInboundContext(head);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user