Why Inbound handler channelRead0() executed twice?

232 views
Skip to first unread message

Wolfgang Flohr-Hochbichler

unread,
Dec 19, 2013, 1:32:21 PM12/19/13
to ne...@googlegroups.com
I've a very simple pipeline configuration, with one InboundHandler.
If I set a breakpoint to the channelRead0 method, the debugger will stop twice and I've no idea why. My first idea was, it has something to do with HttpReponse and HttpContent but in both cases the object (second parameter) is of type  FullHttpRequest. Where is the bug? I'm using Netty 4.0.13.

thank you
-wolfgang

pipeline.addLast("codec-http", new HttpServerCodec(
maxInitialLineLength, maxHeaderSize,
maxChunkSize));
pipeline.addLast("aggregator",new HttpObjectAggregator(maxContentLength));
pipeline.addLast("decompressor",new HttpContentDecompressor());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("handler", new HttpHandler());

public class HttpHandler extends SimpleChannelInboundHandler<Object> {
@Override
protected void channelRead0(
ChannelHandlerContext ctx, Object object)
throws Exception {
if (object instanceof FullHttpRequest) {
FullHttpResponse resp = handleHttpRequest((FullHttpRequest)object);

if (resp != null) {
sendHttpResponse(ctx, (FullHttpRequest)object, resp);
} else {
ctx.fireChannelRead(object);
}
} else {
ctx.fireChannelRead(object);
}
}
}

cyfl...@googlemail.com

unread,
Dec 21, 2013, 1:51:21 AM12/21/13
to ne...@googlegroups.com, wflo...@gmail.com
Problem solved:

I used SimpleChannelInboundHandler with auto_release = false, and forgot to manually release the message: ReferenceCountUtil.release(msg)
Reply all
Reply to author
Forward
0 new messages