From 3579165d72ddd2641093a658ae5313522a298245 Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Thu, 18 Apr 2019 23:47:02 -0700 Subject: [PATCH] SmtpRequestEncoderTest ByteBuf leak (#9075) Motivation: SmtpRequestEncoderTest#testThrowsIfContentExpected has a ByteBuf leak. Modifications: - SmtpRequestEncoderTest#testThrowsIfContentExpected should release buffers in a finally block Result: No more leaks in SmtpRequestEncoderTest#testThrowsIfContentExpected. --- .../handler/codec/smtp/SmtpRequestEncoderTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java index 7717b15139..fb14514922 100644 --- a/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java +++ b/codec-smtp/src/test/java/io/netty/handler/codec/smtp/SmtpRequestEncoderTest.java @@ -22,7 +22,9 @@ import io.netty.handler.codec.EncoderException; import io.netty.util.CharsetUtil; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class SmtpRequestEncoderTest { @@ -92,8 +94,12 @@ public class SmtpRequestEncoderTest { @Test(expected = EncoderException.class) public void testThrowsIfContentExpected() { EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder()); - assertTrue(channel.writeOutbound(SmtpRequests.data())); - channel.writeOutbound(SmtpRequests.noop()); + try { + assertTrue(channel.writeOutbound(SmtpRequests.data())); + channel.writeOutbound(SmtpRequests.noop()); + } finally { + channel.finishAndReleaseAll(); + } } @Test