Hi,
I recently got a race condition issue within netty. I am writing a client library, and in my implementation of "SimpleChannelInboundHandler", I have channelRead0() and channelInactive().
My client communicates with a server. The server will close channel if it feels something wrong, and what the server does is: 1) send 400 response to the client; 2) close the channel.
However, on the client side, there is a rare chance that channelInactive gets called before channelRead0 for the last http content. This happens rarely, only when the network is extremely good. So my question is: 1) is this expected from Netty? 2) how to ensure that channelInactive gets called after the last http content is processed?
Thanks,
Ming
Code snippet
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// abort request
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
// ...
if (msg instanceof HttpContent) {
// ...
if (msg instanceof LastHttpContent) {
// complete request
}
}
}