Remove confusing ChannelState/OperationHandlerAdapter.inboundBufferUpdated/flush() implementation
This commit is contained in:
parent
d385cba41c
commit
b4eaedf712
@ -152,6 +152,11 @@ public class ChunkedWriteHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
doFlush(ctx);
|
||||
|
@ -107,14 +107,12 @@ public class WriteTimeoutHandler extends ChannelOperationHandlerAdapter {
|
||||
@Override
|
||||
public void flush(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
|
||||
scheduleTimeout(ctx, promise);
|
||||
|
||||
super.flush(ctx, promise);
|
||||
ctx.flush(promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFile(ChannelHandlerContext ctx, FileRegion region, ChannelPromise promise) throws Exception {
|
||||
scheduleTimeout(ctx, promise);
|
||||
|
||||
super.sendFile(ctx, region, promise);
|
||||
}
|
||||
|
||||
|
@ -91,26 +91,6 @@ public abstract class ChannelDuplexHandler extends ChannelStateHandlerAdapter im
|
||||
ctx.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#flush(ChannelPromise)} to forward
|
||||
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
|
||||
*
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*
|
||||
* Be aware that if your class also implement {@link ChannelOutboundHandler} it need to {@code @Override} this
|
||||
* method and provide some proper implementation. Fail to do so, will result in an {@link IllegalStateException}!
|
||||
*/
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx, ChannelPromise future)
|
||||
throws Exception {
|
||||
if (this instanceof ChannelOutboundHandler) {
|
||||
throw new IllegalStateException(
|
||||
"flush(...) must be overridden by " + getClass().getName() +
|
||||
", which implements " + ChannelOutboundHandler.class.getSimpleName());
|
||||
}
|
||||
ctx.flush(future);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#sendFile(FileRegion, ChannelPromise)} to forward
|
||||
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
|
||||
|
@ -83,4 +83,9 @@ public abstract class ChannelInitializer<C extends Channel> extends ChannelState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
}
|
||||
|
@ -84,26 +84,6 @@ public abstract class ChannelOperationHandlerAdapter extends ChannelHandlerAdapt
|
||||
ctx.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#flush(ChannelPromise)} to forward
|
||||
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
|
||||
*
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*
|
||||
* Be aware that if your class also implement {@link ChannelOutboundHandler} it need to {@code override} this
|
||||
* method!
|
||||
*/
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx, ChannelPromise promise)
|
||||
throws Exception {
|
||||
if (this instanceof ChannelOutboundHandler) {
|
||||
throw new IllegalStateException(
|
||||
"flush(...) must be overridden by " + getClass().getName() +
|
||||
", which implements " + ChannelOutboundHandler.class.getSimpleName());
|
||||
}
|
||||
ctx.flush(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#sendFile(FileRegion, ChannelPromise)} to forward
|
||||
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
|
||||
|
@ -69,25 +69,6 @@ public abstract class ChannelStateHandlerAdapter extends ChannelHandlerAdapter i
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link ChannelHandlerContext#fireInboundBufferUpdated()} to forward
|
||||
* to the next {@link ChannelOperationHandler} in the {@link ChannelPipeline}.
|
||||
*
|
||||
* Sub-classes may override this method to change behavior.
|
||||
*
|
||||
* Be aware that if your class also implement {@link ChannelInboundHandler} it need to {@code @Override} this
|
||||
* method and provide some proper implementation. Fail to do so, will result in an {@link IllegalStateException}!
|
||||
*/
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
if (this instanceof ChannelInboundHandler) {
|
||||
throw new IllegalStateException(
|
||||
"inboundBufferUpdated(...) must be overridden by " + getClass().getName() +
|
||||
", which implements " + ChannelInboundHandler.class.getSimpleName());
|
||||
}
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelReadSuspended(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireChannelReadSuspended();
|
||||
|
@ -60,11 +60,26 @@ public abstract class AbstractEventLoopTest {
|
||||
}
|
||||
|
||||
private static final class TestChannelHandler extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.flush(promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TestChannelHandler2 extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.flush(promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract EventLoopGroup newEventLoopGroup();
|
||||
|
@ -328,6 +328,14 @@ public class DefaultChannelPipelineTest {
|
||||
|
||||
@Sharable
|
||||
private static class TestHandler extends ChannelDuplexHandler {
|
||||
// Dummy
|
||||
@Override
|
||||
public void flush(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
ctx.flush(promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.fireInboundBufferUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user