Http2ConnectionHandler channelInactive sequencing

Motivation:
ByteToMessageDecoder may call decode after channelInactive is called. This will lead to a NPE.

Modifications:
- Call super.channelInactive() before we process the event in Http2ConnectionHandler

Result:
No more NPE in decode.
This commit is contained in:
Scott Mitchell 2015-08-20 19:23:37 -07:00
parent e280251b15
commit 14dc571956

View File

@ -417,11 +417,12 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// Call super class first, as this may result in decode being called.
super.channelInactive(ctx);
if (byteDecoder != null) { if (byteDecoder != null) {
encoder.flowController().channelHandlerContext(null); encoder.flowController().channelHandlerContext(null);
decoder.flowController().channelHandlerContext(null); decoder.flowController().channelHandlerContext(null);
byteDecoder.channelInactive(ctx); byteDecoder.channelInactive(ctx);
super.channelInactive(ctx);
byteDecoder = null; byteDecoder = null;
} }
} }