ChannelHandler.handlerRemoved() must be invoked *after* the handler has been removed completely and its buffers should be inaccessible.

This commit is contained in:
Trustin Lee 2013-04-24 18:46:35 +09:00
parent a68d39fcf2
commit c72b5341a3
2 changed files with 4 additions and 4 deletions

View File

@ -190,12 +190,13 @@ import java.lang.annotation.Target;
public interface ChannelHandler {
/**
* Gets called after the {@link ChannelHandler} was added to the actual context.
* Gets called after the {@link ChannelHandler} was added to the actual context and it's ready to handle events.
*/
void handlerAdded(ChannelHandlerContext ctx) throws Exception;
/**
* Gets called after the {@link ChannelHandler} was removed from the actual context.
* Gets called after the {@link ChannelHandler} was removed from the actual context and it doesn't handle events
* anymore.
*/
void handlerRemoved(ChannelHandlerContext ctx) throws Exception;

View File

@ -548,14 +548,13 @@ final class DefaultChannelPipeline implements ChannelPipeline {
// Notify the complete removal.
try {
ctx.forwardBufferContentAndRemove(ctxPrev, ctxNext);
handler.handlerRemoved(ctx);
} catch (Throwable t) {
fireExceptionCaught(new ChannelPipelineException(
ctx.handler().getClass().getName() +
".afterRemove() has thrown an exception.", t));
}
ctx.forwardBufferContentAndRemove(ctxPrev, ctxNext);
}
/**