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.
This commit is contained in:
Scott Mitchell 2019-04-18 23:47:02 -07:00 committed by Norman Maurer
parent d9c23a1e5b
commit 4e37689774

View File

@ -22,7 +22,9 @@ import io.netty.handler.codec.EncoderException;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
import org.junit.Test; 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 { public class SmtpRequestEncoderTest {
@ -92,8 +94,12 @@ public class SmtpRequestEncoderTest {
@Test(expected = EncoderException.class) @Test(expected = EncoderException.class)
public void testThrowsIfContentExpected() { public void testThrowsIfContentExpected() {
EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder()); EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder());
try {
assertTrue(channel.writeOutbound(SmtpRequests.data())); assertTrue(channel.writeOutbound(SmtpRequests.data()));
channel.writeOutbound(SmtpRequests.noop()); channel.writeOutbound(SmtpRequests.noop());
} finally {
channel.finishAndReleaseAll();
}
} }
@Test @Test