From 016f1b98bda6733f25102824e43fa86ade8cedd5 Mon Sep 17 00:00:00 2001 From: sullis Date: Sun, 25 Feb 2024 09:54:44 -0800 Subject: [PATCH] enable leak detector in reactor-netty-core --- reactor-netty-core/build.gradle | 1 + .../src/test/java/reactor/netty/ByteBufFluxTest.java | 3 +++ .../src/test/java/reactor/netty/ByteBufMonoTest.java | 3 +++ .../src/test/java/reactor/netty/ConnectionTest.java | 3 +++ .../src/test/java/reactor/netty/NettyOutboundTest.java | 3 +++ .../src/test/java/reactor/netty/ReactorNettyTest.java | 3 +++ 6 files changed, 16 insertions(+) diff --git a/reactor-netty-core/build.gradle b/reactor-netty-core/build.gradle index 8c7484eb6e..1523d57a46 100644 --- a/reactor-netty-core/build.gradle +++ b/reactor-netty-core/build.gradle @@ -133,6 +133,7 @@ dependencies { testImplementation "org.awaitility:awaitility:$awaitilityVersion" testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion" + testImplementation "io.github.nettyplus:netty-leak-detector-junit-extension:$nettyLeakDetectorJunitExtensionVersion" testImplementation "org.mockito:mockito-core:$mockitoVersion" testImplementation "ch.qos.logback:logback-classic:$logbackVersion" testImplementation "io.projectreactor.tools:blockhound-junit-platform:$blockHoundVersion" diff --git a/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java b/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java index 95e9d0ea00..670af6e2ae 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java @@ -15,10 +15,12 @@ */ package reactor.netty; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import io.netty.buffer.ByteBuf; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -38,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; +@ExtendWith(NettyLeakDetectorExtension.class) class ByteBufFluxTest { private static File temporaryDirectory; diff --git a/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java b/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java index 6366949145..73722b5d65 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java @@ -15,7 +15,9 @@ */ package reactor.netty; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -24,6 +26,7 @@ import java.nio.charset.Charset; import java.time.Duration; +@ExtendWith(NettyLeakDetectorExtension.class) class ByteBufMonoTest { @Test diff --git a/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java b/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java index 6a4214e778..31a29d1606 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiConsumer; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerAdapter; @@ -30,6 +31,7 @@ import io.netty.handler.codec.http.websocketx.Utf8FrameValidator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import reactor.core.Disposable; import reactor.core.publisher.Mono; @@ -42,6 +44,7 @@ * @author Simon Baslé * @author Violeta Georgieva */ +@ExtendWith(NettyLeakDetectorExtension.class) class ConnectionTest { static final BiConsumer ADD_EXTRACTOR = ChannelHandlerContext::fireChannelRead; diff --git a/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java b/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java index 3926d5717e..e43c43e978 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/NettyOutboundTest.java @@ -33,6 +33,7 @@ import java.util.function.Predicate; import javax.net.ssl.SSLException; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.ChannelFuture; @@ -52,11 +53,13 @@ import io.netty.util.ReferenceCountUtil; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import static org.assertj.core.api.Assertions.assertThat; +@ExtendWith(NettyLeakDetectorExtension.class) class NettyOutboundTest { static SelfSignedCertificate ssc; diff --git a/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java b/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java index 2143c4f496..881f47ee65 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java @@ -15,6 +15,7 @@ */ package reactor.netty; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import io.netty.channel.AbstractChannel; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; @@ -23,6 +24,7 @@ import io.netty.channel.EventLoop; import io.netty.channel.embedded.EmbeddedChannel; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import reactor.util.annotation.Nullable; import java.net.InetSocketAddress; @@ -35,6 +37,7 @@ * * @author Violeta Georgieva */ +@ExtendWith(NettyLeakDetectorExtension.class) class ReactorNettyTest { /*