diff --git a/build.gradle b/build.gradle index 14895d85f3..0aba5dc9ac 100644 --- a/build.gradle +++ b/build.gradle @@ -129,6 +129,7 @@ ext { awaitilityVersion = '4.2.1' hoverflyJavaVersion = '0.18.1' tomcatVersion = '9.0.89' + nettyLeakDetectorJunitExtensionVersion = "0.0.5" boringSslVersion = '2.0.65.Final' junitVersion = '5.10.2' junitPlatformLauncherVersion = '1.10.2' diff --git a/reactor-netty-core/build.gradle b/reactor-netty-core/build.gradle index 0aabb26620..400216fa92 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..d12b339b51 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ByteBufFluxTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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..8d18e1702f 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ByteBufMonoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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..466c39e071 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ConnectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2017-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 c976f230f2..784451e0f9 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..03f729263d 100644 --- a/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java +++ b/reactor-netty-core/src/test/java/reactor/netty/ReactorNettyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2021-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 { /* diff --git a/reactor-netty-http/build.gradle b/reactor-netty-http/build.gradle index 7653d6cafa..1a3679cfcd 100644 --- a/reactor-netty-http/build.gradle +++ b/reactor-netty-http/build.gradle @@ -134,6 +134,7 @@ dependencies { testImplementation "org.mockito:mockito-core:$mockitoVersion" testImplementation "io.specto:hoverfly-java-junit5:$hoverflyJavaVersion" + testImplementation "io.github.nettyplus:netty-leak-detector-junit-extension:$nettyLeakDetectorJunitExtensionVersion" testImplementation "org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion" testImplementation "io.projectreactor:reactor-test:$testAddonVersion" testImplementation "org.assertj:assertj-core:$assertJVersion" diff --git a/reactor-netty-http/src/test/java/reactor/netty/BaseHttpTest.java b/reactor-netty-http/src/test/java/reactor/netty/BaseHttpTest.java index 9e6633dc59..94ff451a50 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/BaseHttpTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/BaseHttpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2021-2024 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,9 @@ */ package reactor.netty; +import io.github.nettyplus.leakdetector.junit.NettyLeakDetectorExtension; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.provider.Arguments; import reactor.netty.http.HttpProtocol; import reactor.netty.http.client.HttpClient; @@ -34,6 +36,7 @@ * @author Violeta Georgieva * @since 1.0.3 */ +@ExtendWith(NettyLeakDetectorExtension.class) public class BaseHttpTest { protected DisposableServer disposableServer;