From 36d5d0ea27eb2efa500c93fc3247e0fa9b57cccd Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Thu, 20 Aug 2015 19:23:37 -0700 Subject: [PATCH] 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. --- .../io/netty/handler/codec/http2/Http2ConnectionHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java index 11fd214c16..a19fb0c60e 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java @@ -414,11 +414,12 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http @Override 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) { encoder.flowController().channelHandlerContext(null); decoder.flowController().channelHandlerContext(null); byteDecoder.channelInactive(ctx); - super.channelInactive(ctx); byteDecoder = null; } }