Make sure WebSocketFrameAggregator and HttpObjectAggregator don't leak ByteBufs

This commit is contained in:
Norman Maurer 2013-06-11 08:53:14 +02:00
parent 16e12b45f8
commit e3ec124ccd
2 changed files with 44 additions and 0 deletions

View File

@ -210,8 +210,30 @@ public class HttpObjectAggregator extends MessageToMessageDecoder<HttpObject> {
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
// release current message if it is not null as it may be a left-over
if (currentMessage != null) {
currentMessage.release();
currentMessage = null;
}
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
super.handlerRemoved(ctx);
// release current message if it is not null as it may be a left-over as there is not much more we can do in
// this case
if (currentMessage != null) {
currentMessage.release();
currentMessage = null;
}
}
}

View File

@ -97,4 +97,26 @@ public class WebSocketFrameAggregator extends MessageToMessageDecoder<WebSocketF
// handler in the chain
out.add(msg.retain());
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
// release current frame if it is not null as it may be a left-over
if (currentFrame != null) {
currentFrame.release();
currentFrame = null;
}
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
super.handlerRemoved(ctx);
// release current frane if it is not null as it may be a left-over as there is not much more we can do in
// this case
if (currentFrame != null) {
currentFrame.release();
currentFrame = null;
}
}
}