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
7dac4fdd25
commit
55c291ae5b
@ -87,6 +87,11 @@ public class SslHandlerTest {
|
|||||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[]{2, 0, 0, 1, 0}));
|
ch.writeInbound(Unpooled.wrappedBuffer(new byte[]{2, 0, 0, 1, 0}));
|
||||||
fail();
|
fail();
|
||||||
} catch (DecoderException e) {
|
} 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.
|
// The pushed message is invalid, so it should raise an exception if it decoded the message correctly.
|
||||||
assertThat(e.getCause(), is(instanceOf(SSLProtocolException.class)));
|
assertThat(e.getCause(), is(instanceOf(SSLProtocolException.class)));
|
||||||
}
|
}
|
||||||
@ -99,7 +104,11 @@ public class SslHandlerTest {
|
|||||||
|
|
||||||
EmbeddedChannel ch = new EmbeddedChannel(new SslHandler(engine));
|
EmbeddedChannel ch = new EmbeddedChannel(new SslHandler(engine));
|
||||||
|
|
||||||
ch.writeOutbound(new Object());
|
try {
|
||||||
|
ch.writeOutbound(new Object());
|
||||||
|
} finally {
|
||||||
|
ch.finishAndReleaseAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -118,6 +127,7 @@ public class SslHandlerTest {
|
|||||||
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
||||||
assertEquals(1, ((ReferenceCounted) sslEngine).refCnt());
|
assertEquals(1, ((ReferenceCounted) sslEngine).refCnt());
|
||||||
|
|
||||||
|
assertTrue(ch.finishAndReleaseAll());
|
||||||
ch.close().syncUninterruptibly();
|
ch.close().syncUninterruptibly();
|
||||||
|
|
||||||
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
assertEquals(1, ((ReferenceCounted) sslContext).refCnt());
|
||||||
|
Loading…
Reference in New Issue
Block a user