Http2MultiplexCodec should propagate unhandled Http2Frames down the pipeline

Motivation:

Http2MultiplexCodec swallows Http2PingFrames without releasing the payload, resulting in a memory leak.

Modification:

Send unhandled frames down the pipeline for consumption/disposal by another InboundChannelHandler.

Result:

Fixes #7607.
This commit is contained in:
Bryce Anderson 2018-01-25 14:26:45 -07:00 committed by Scott Mitchell
parent f0c76cacc3
commit 8a095d0244
2 changed files with 14 additions and 0 deletions

View File

@ -227,6 +227,9 @@ public class Http2MultiplexCodec extends Http2FrameCodec {
if (settings.initialWindowSize() != null) {
initialOutboundStreamWindow = settings.initialWindowSize();
}
} else {
// Send any other frames down the pipeline
ctx.fireChannelRead(frame);
}
}

View File

@ -170,6 +170,17 @@ public class Http2MultiplexCodecTest {
verifyFramesMultiplexedToCorrectChannel(inboundStream, inboundHandler, 2);
}
@Test
public void unhandledHttp2FramesShouldBePropagated() {
ByteBuf content = UnpooledByteBufAllocator.DEFAULT.buffer(8).writeLong(0);
Http2PingFrame decodedFrame = new DefaultHttp2PingFrame(content);
codec.onHttp2Frame(decodedFrame);
Http2PingFrame receivedPing = parentChannel.readInbound();
assertSame(receivedPing, decodedFrame);
assertTrue(receivedPing.release());
}
@Test
public void channelReadShouldRespectAutoRead() {
LastInboundHandler inboundHandler = streamActiveAndWriteHeaders(inboundStream);