diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 7d67ce7b3f..07a2007ff7 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -99,6 +99,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements private Runnable fireInboundBufferUpdated0Task; private Runnable invokeChannelReadSuspendedTask; private Runnable invokeRead0Task; + private boolean freed; boolean removed; @SuppressWarnings("unchecked") @@ -350,9 +351,10 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } void freeHandlerBuffersAfterRemoval() { - if (!removed) { + if (!removed || freed) { return; } + freed = true; final ChannelHandler handler = handler(); if (handler instanceof ChannelInboundHandler) {