Fix IllegalReferenceCountException when using Http2MultiplexCodec and a DefaultHttp2GoAwayFrame with a non empty ByteBuffer is received. (#7894)

Motivation:

We incorrectly called frame.release() in onHttp2GoAwayFrame which could lead to IllegalReferenceCountExceptions.  The call of release() is inappropriate because the fireChannelRead() in onHttp2Frame() will handle it.

Modifications:

- Not call frame.release()
- Add a unit test

Result:

Fxies https://github.com/netty/netty/issues/7892.
This commit is contained in:
Norman Maurer 2018-04-28 22:03:49 +02:00 committed by GitHub
parent c0ae5e697c
commit dfeb4b15b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -337,9 +337,6 @@ public class Http2MultiplexCodec extends Http2FrameCodec {
} catch (Http2Exception e) {
ctx.fireExceptionCaught(e);
ctx.close();
} finally {
// We need to ensure we release the goAwayFrame.
goAwayFrame.release();
}
}

View File

@ -183,9 +183,13 @@ public class Http2MultiplexCodecTest {
codec.onHttp2Frame(pingFrame);
assertSame(parentChannel.readInbound(), pingFrame);
DefaultHttp2GoAwayFrame goAwayFrame = new DefaultHttp2GoAwayFrame(1);
DefaultHttp2GoAwayFrame goAwayFrame =
new DefaultHttp2GoAwayFrame(1, parentChannel.alloc().buffer().writeLong(8));
codec.onHttp2Frame(goAwayFrame);
assertSame(parentChannel.readInbound(), goAwayFrame);
Http2GoAwayFrame frame = parentChannel.readInbound();
assertSame(frame, goAwayFrame);
assertTrue(frame.release());
}
@Test