From 1a47b7745d60273cb72b2ef015c88c2bbe6fa507 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 10 Aug 2026 17:00:08 +0200 Subject: [PATCH] Use new resource API. Motiation: Vert.x core has introduced new API for resource cleanup. This project should use it. Changes: Use new resource cleanup API. --- .../shell/command/impl/CommandRegistryImpl.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/vertx/ext/shell/command/impl/CommandRegistryImpl.java b/src/main/java/io/vertx/ext/shell/command/impl/CommandRegistryImpl.java index 66b3d316..b320d633 100644 --- a/src/main/java/io/vertx/ext/shell/command/impl/CommandRegistryImpl.java +++ b/src/main/java/io/vertx/ext/shell/command/impl/CommandRegistryImpl.java @@ -55,22 +55,21 @@ public static CommandRegistry get(Vertx vertx) { final VertxInternal vertx; final ConcurrentHashMap commandMap = new ConcurrentHashMap<>(); - final Closeable hook; private volatile boolean closed; public CommandRegistryImpl(VertxInternal vertx) { - this.vertx = vertx; - hook = completionHandler -> { + + vertx.registerResource(timeout -> { try { doClose(); registries.remove(vertx); } catch (Exception e) { - completionHandler.fail(e); - return; + return Future.failedFuture(e); } - completionHandler.succeed(); - }; - vertx.addCloseHook(hook); + return Future.succeededFuture(); + }); + + this.vertx = vertx; } private void doClose() {