Fix a bug where ChannelPIpeline.remove/replace() fails when its channel is not registered yet
This commit is contained in:
parent
e263769a55
commit
573a723dc2
@ -611,25 +611,33 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
if (channel.isRegistered()) {
|
||||
ctx.executor().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
freeHandlerBuffers(handler, ctx);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
freeHandlerBuffers(handler, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private void freeHandlerBuffers(ChannelHandler handler, ChannelHandlerContext ctx) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user