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
|
@Override
|
||||||
public ChannelFuture bind(SocketAddress localAddress) {
|
public ChannelFuture bind(SocketAddress localAddress) {
|
||||||
return pipeline().bind(localAddress, newFuture());
|
return pipeline().bind(localAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture connect(SocketAddress remoteAddress) {
|
public ChannelFuture connect(SocketAddress remoteAddress) {
|
||||||
return pipeline().connect(remoteAddress, newFuture());
|
return pipeline().connect(remoteAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) {
|
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) {
|
||||||
return pipeline().connect(remoteAddress, localAddress, newFuture());
|
return pipeline().connect(remoteAddress, localAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture disconnect() {
|
public ChannelFuture disconnect() {
|
||||||
return pipeline().disconnect(newFuture());
|
return pipeline().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture close() {
|
public ChannelFuture close() {
|
||||||
return pipeline().close(newFuture());
|
return pipeline().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture deregister() {
|
public ChannelFuture deregister() {
|
||||||
return pipeline().deregister(newFuture());
|
return pipeline().deregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture flush() {
|
public ChannelFuture flush() {
|
||||||
return pipeline().flush(newFuture());
|
return pipeline().flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture write(Object message) {
|
public ChannelFuture write(Object message) {
|
||||||
return pipeline().write(message, newFuture());
|
return pipeline().write(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -706,6 +706,8 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
if (localAddress == null) {
|
if (localAddress == null) {
|
||||||
throw new NullPointerException("localAddress");
|
throw new NullPointerException("localAddress");
|
||||||
}
|
}
|
||||||
|
validateFuture(future);
|
||||||
|
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
((ChannelOutboundHandler<Object>) ctx.handler()).bind(ctx, localAddress, future);
|
((ChannelOutboundHandler<Object>) ctx.handler()).bind(ctx, localAddress, future);
|
||||||
@ -733,6 +735,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
if (remoteAddress == null) {
|
if (remoteAddress == null) {
|
||||||
throw new NullPointerException("remoteAddress");
|
throw new NullPointerException("remoteAddress");
|
||||||
}
|
}
|
||||||
|
validateFuture(future);
|
||||||
|
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
@ -754,6 +757,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private ChannelFuture disconnect(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
private ChannelFuture disconnect(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
|
validateFuture(future);
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
((ChannelOutboundHandler<Object>) ctx.handler()).disconnect(ctx, future);
|
((ChannelOutboundHandler<Object>) ctx.handler()).disconnect(ctx, future);
|
||||||
@ -774,6 +778,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private ChannelFuture close(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
private ChannelFuture close(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
|
validateFuture(future);
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
((ChannelOutboundHandler<Object>) ctx.handler()).close(ctx, future);
|
((ChannelOutboundHandler<Object>) ctx.handler()).close(ctx, future);
|
||||||
@ -794,6 +799,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private ChannelFuture deregister(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
private ChannelFuture deregister(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
|
validateFuture(future);
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
((ChannelOutboundHandler<Object>) ctx.handler()).deregister(ctx, future);
|
((ChannelOutboundHandler<Object>) ctx.handler()).deregister(ctx, future);
|
||||||
@ -814,6 +820,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private ChannelFuture flush(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
private ChannelFuture flush(DefaultChannelHandlerContext ctx, ChannelFuture future) {
|
||||||
|
validateFuture(future);
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
try {
|
try {
|
||||||
((ChannelOutboundHandler<Object>) ctx.handler()).flush(ctx, future);
|
((ChannelOutboundHandler<Object>) ctx.handler()).flush(ctx, future);
|
||||||
@ -829,6 +836,11 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture write(Object message, ChannelFuture future) {
|
public ChannelFuture write(Object message, ChannelFuture future) {
|
||||||
|
if (message == null) {
|
||||||
|
throw new NullPointerException("message");
|
||||||
|
}
|
||||||
|
validateFuture(future);
|
||||||
|
|
||||||
if (message instanceof ChannelBuffer) {
|
if (message instanceof ChannelBuffer) {
|
||||||
ChannelBuffer m = (ChannelBuffer) message;
|
ChannelBuffer m = (ChannelBuffer) message;
|
||||||
out().byteBuffer().writeBytes(m, m.readerIndex(), m.readableBytes());
|
out().byteBuffer().writeBytes(m, m.readerIndex(), m.readableBytes());
|
||||||
@ -838,6 +850,16 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
return flush(future);
|
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() {
|
private DefaultChannelHandlerContext firstInboundContext() {
|
||||||
return nextInboundContext(head);
|
return nextInboundContext(head);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user