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

This commit is contained in:
Trustin Lee 2012-08-20 13:40:58 +09:00
parent bf74b16774
commit a93ada2031
2 changed files with 38 additions and 2 deletions

View File

@ -20,6 +20,7 @@ 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.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
@ -43,7 +44,8 @@ import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
* so that this handler can intercept HTTP requests after {@link HttpMessageDecoder}
* converts {@link ChannelBuffer}s into HTTP requests.
*/
public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler {
public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler
implements LifeCycleAwareChannelHandler {
private DecoderEmbedder<ChannelBuffer> decoder;
@ -183,4 +185,20 @@ public abstract class HttpContentDecoder extends SimpleChannelUpstreamHandler {
decoder = null;
return result;
}
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
finishDecode();
}
}

View File

@ -23,6 +23,7 @@ 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.LifeCycleAwareChannelHandler;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
@ -48,7 +49,8 @@ import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
* so that this handler can intercept HTTP responses before {@link HttpMessageEncoder}
* converts them into {@link ChannelBuffer}s.
*/
public abstract class HttpContentEncoder extends SimpleChannelHandler {
public abstract class HttpContentEncoder extends SimpleChannelHandler
implements LifeCycleAwareChannelHandler {
private final Queue<String> acceptEncodingQueue = new ConcurrentLinkedQueue<String>();
private volatile EncoderEmbedder<ChannelBuffer> encoder;
@ -215,4 +217,20 @@ public abstract class HttpContentEncoder extends SimpleChannelHandler {
encoder = null;
return result;
}
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// NOOP
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
finishEncode();
}
}