Fix a bug where HttpContentDecoder emits duplicate HttpMessage or raises NPE

This commit is contained in:
Trustin Lee 2013-02-10 01:35:01 +09:00
parent 61bbb04852
commit 27190fcb7f
2 changed files with 9 additions and 5 deletions

View File

@ -56,7 +56,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
if (msg instanceof HttpMessage) { if (msg instanceof HttpMessage) {
assert message == null; assert message == null;
message = (HttpMessage) msg; message = (HttpMessage) msg;
decodeStarted = false;
cleanup(); cleanup();
} }
@ -100,11 +100,15 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
} }
return new Object[] { message, c }; return new Object[] { message, c };
} }
if (decoder != null) {
return decodeContent(null, c); return decodeContent(null, c);
} else {
return c;
}
} }
// Because FullHttpMessage and HttpChunk is a mutable object, we can simply forward it. return null;
return msg;
} }
@Override @Override

View File

@ -56,7 +56,7 @@ public class HttpSnoopClientInitializer extends ChannelInitializer<SocketChannel
p.addLast("inflater", new HttpContentDecompressor()); p.addLast("inflater", new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpChunks. // Uncomment the following line if you don't want to handle HttpChunks.
//pipeline.addLast("aggregator", new HttpChunkAggregator(1048576)); //p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("handler", new HttpSnoopClientHandler()); p.addLast("handler", new HttpSnoopClientHandler());
} }