Skip to content

Commit 262f9e4

Browse files
authored
Fix ScopedObject cleanup for JUnit 5.9.x compatibility (#155) (#156) (#157)
See #155 ScopedObject must implement both ExtensionContext.Store.CloseableResource and AutoCloseable to ensure proper cleanup across all JUnit 5.x versions. JUnit 5.9.x and earlier only recognize CloseableResource for automatic cleanup. Without it, ScopedObject.close() is never called, causing resources (Vertx instances, HTTP servers) to leak between test iterations. JUnit 5.11+ added AutoCloseable support, but we need both interfaces for backward compatibility with users on older JUnit versions. Signed-off-by: Thomas Segismont <[email protected]>
1 parent 5e9e371 commit 262f9e4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/io/vertx/junit5/ScopedObject.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.vertx.junit5;
1818

19+
import org.junit.jupiter.api.extension.ExtensionContext;
20+
1921
import java.util.Objects;
2022
import java.util.function.Supplier;
2123

@@ -27,7 +29,7 @@
2729
* @param <T> Parameter type
2830
* @author <a href="https://julien.ponge.org/">Julien Ponge</a>
2931
*/
30-
public class ScopedObject<T> implements Supplier<T>, AutoCloseable {
32+
public class ScopedObject<T> implements Supplier<T>, ExtensionContext.Store.CloseableResource, AutoCloseable {
3133

3234
private T object;
3335
private final ParameterClosingConsumer<T> cleaner;

0 commit comments

Comments
 (0)