SslHandlerTest ByteBuf leak
Motivation: We are now more careful to flush alerts that are generated when errors occur. We should also be more careful in unit tests to release any buffers that may be queued due to potential errors wich result in alerts. Modifications: - When SslHandlerTest uses EmbeddedChannel we should always call finishAndReleaseAll Results: Fixes https://github.com/netty/netty/issues/6057
This commit is contained in:
parent
ba0542e397
commit
24d0f3d45d
@ -90,6 +90,11 @@ public class SslHandlerTest {
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[]{2, 0, 0, 1, 0}));
|
||||
fail();
|
||||
} catch (DecoderException e) {
|
||||
// Be sure we cleanup the channel and release any pending messages that may have been generated because
|
||||
// of an alert.
|
||||
// See https://github.com/netty/netty/issues/6057.
|
||||
ch.finishAndReleaseAll();
|
||||
|
||||
// The pushed message is invalid, so it should raise an exception if it decoded the message correctly.
|
||||
assertThat(e.getCause(), is(instanceOf(SSLProtocolException.class)));
|
||||
}
|
||||
@ -102,7 +107,11 @@ public class SslHandlerTest {
|
||||
|
||||
EmbeddedChannel ch = new EmbeddedChannel(new SslHandler(engine));
|
||||
|
||||
ch.writeOutbound(new Object());
|
||||
try {
|
||||
ch.writeOutbound(new Object());
|
||||
} finally {
|
||||
ch.finishAndReleaseAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -121,6 +130,7 @@ public class SslHandlerTest {
|
||||
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
||||
assertEquals(1, ((ReferenceCounted) sslEngine).refCnt());
|
||||
|
||||
assertTrue(ch.finishAndReleaseAll());
|
||||
ch.close().syncUninterruptibly();
|
||||
|
||||
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
||||
|
Loading…
x
Reference in New Issue
Block a user