[#539] Potential direct memory leak in HttpContentEn/Decoder

This commit is contained in:
Trustin Lee 2012-08-20 13:35:12 +09:00
parent 88c3fd306b
commit bf74b16774
2 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package org.jboss.netty.handler.codec.http;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
@ -132,6 +133,14 @@ public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler {
}
}
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// Clean-up the previous decoder if not cleaned up correctly.
finishDecode();
super.channelClosed(ctx, e);
}
/**
* Returns a new {@link DecoderEmbedder} that decodes the HTTP message
* content encoded in the specified <tt>contentEncoding</tt>.

View File

@ -21,6 +21,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
@ -166,6 +167,14 @@ public abstract class HttpContentEncoder extends SimpleChannelHandler {
}
}
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// Clean-up the previous encoder if not cleaned up correctly.
finishEncode();
super.channelClosed(ctx, e);
}
/**
* Returns a new {@link EncoderEmbedder} that encodes the HTTP message
* content.