Fix memory leak in DefaultChannelHandlerContext

.. where freeInbound() and freeOutbound() are not called for all contexts

- Fixes #1298
This commit is contained in:
Trustin Lee 2013-04-22 22:18:10 +09:00
parent e80fb65c36
commit d85757a008

View File

@ -1467,16 +1467,15 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
private void invokeFreeInboundBuffer0() {
ChannelHandler handler = handler();
if (handler instanceof ChannelInboundHandler) {
ChannelInboundHandler h = (ChannelInboundHandler) handler;
try {
h.freeInboundBuffer(this);
if (handler instanceof ChannelInboundHandler) {
((ChannelInboundHandler) handler).freeInboundBuffer(this);
}
} catch (Throwable t) {
notifyHandlerException(t);
} finally {
freeInbound();
}
}
if (next != null) {
DefaultChannelHandlerContext nextCtx = findContextInbound();
@ -1519,16 +1518,15 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
private void invokeFreeOutboundBuffer0() {
ChannelHandler handler = handler();
if (handler instanceof ChannelOutboundHandler) {
ChannelOutboundHandler h = (ChannelOutboundHandler) handler;
try {
h.freeOutboundBuffer(this);
if (handler instanceof ChannelOutboundHandler) {
((ChannelOutboundHandler) handler).freeOutboundBuffer(this);
}
} catch (Throwable t) {
notifyHandlerException(t);
} finally {
freeOutbound();
}
}
if (prev != null) {
findContextOutbound().invokeFreeOutboundBuffer();