Fix a bug where the buffers are freed too early when a handler is removed or replaced
This commit is contained in:
parent
a03bc6ea1d
commit
e263769a55
@ -598,23 +598,8 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callAfterRemove(ChannelHandlerContext ctx) {
|
private void callAfterRemove(final ChannelHandlerContext ctx) {
|
||||||
// Free all buffers before completing removal.
|
final ChannelHandler handler = ctx.handler();
|
||||||
ChannelHandler handler = ctx.handler();
|
|
||||||
if (handler instanceof ChannelInboundHandler) {
|
|
||||||
try {
|
|
||||||
((ChannelInboundHandler) handler).freeInboundBuffer(ctx);
|
|
||||||
} catch (Exception e) {
|
|
||||||
notifyHandlerException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (handler instanceof ChannelOutboundHandler) {
|
|
||||||
try {
|
|
||||||
((ChannelOutboundHandler) handler).freeOutboundBuffer(ctx);
|
|
||||||
} catch (Exception e) {
|
|
||||||
notifyHandlerException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the complete removal.
|
// Notify the complete removal.
|
||||||
try {
|
try {
|
||||||
@ -624,6 +609,27 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
ctx.handler().getClass().getName() +
|
ctx.handler().getClass().getName() +
|
||||||
".afterRemove() has thrown an exception.", t);
|
".afterRemove() has thrown an exception.", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free all buffers before completing removal.
|
||||||
|
ctx.executor().execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (handler instanceof ChannelInboundHandler) {
|
||||||
|
try {
|
||||||
|
((ChannelInboundHandler) handler).freeInboundBuffer(ctx);
|
||||||
|
} catch (Exception e) {
|
||||||
|
notifyHandlerException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handler instanceof ChannelOutboundHandler) {
|
||||||
|
try {
|
||||||
|
((ChannelOutboundHandler) handler).freeOutboundBuffer(ctx);
|
||||||
|
} catch (Exception e) {
|
||||||
|
notifyHandlerException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user