[#976] Fix exception which will be raised by ChannelInboundHandler.discardInboundReadBytes() and ChannelOutboundHandler.discardOutboundReadBytes() if the handler remove it self from the pipeline
This commit is contained in:
parent
a25f7fa2e5
commit
3f72add89a
@ -80,6 +80,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
private Runnable invokeFreeInboundBuffer0Task;
|
||||
private Runnable invokeFreeOutboundBuffer0Task;
|
||||
private Runnable invokeRead0Task;
|
||||
boolean removed;
|
||||
|
||||
DefaultChannelHandlerContext(
|
||||
DefaultChannelPipeline pipeline, EventExecutorGroup group,
|
||||
@ -1084,7 +1085,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
} catch (Throwable t) {
|
||||
pipeline.notifyHandlerException(t);
|
||||
} finally {
|
||||
if (handler instanceof ChannelInboundByteHandler && !isInboundBufferFreed()) {
|
||||
if (!removed && handler instanceof ChannelInboundByteHandler && !isInboundBufferFreed()) {
|
||||
try {
|
||||
((ChannelInboundByteHandler) handler).discardInboundReadBytes(this);
|
||||
} catch (Throwable t) {
|
||||
@ -1424,7 +1425,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
} catch (Throwable t) {
|
||||
pipeline.notifyHandlerException(t);
|
||||
} finally {
|
||||
if (handler instanceof ChannelOutboundByteHandler && !isOutboundBufferFreed()) {
|
||||
if (!removed && handler instanceof ChannelOutboundByteHandler && !isOutboundBufferFreed()) {
|
||||
try {
|
||||
((ChannelOutboundByteHandler) handler).discardOutboundReadBytes(this);
|
||||
} catch (Throwable t) {
|
||||
|
@ -599,7 +599,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void callAfterRemove(final ChannelHandlerContext ctx) {
|
||||
private void callAfterRemove(final DefaultChannelHandlerContext ctx) {
|
||||
final ChannelHandler handler = ctx.handler();
|
||||
|
||||
// Notify the complete removal.
|
||||
@ -622,6 +622,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
} else {
|
||||
freeHandlerBuffers(handler, ctx);
|
||||
}
|
||||
ctx.removed = true;
|
||||
}
|
||||
|
||||
private void freeHandlerBuffers(ChannelHandler handler, ChannelHandlerContext ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user