From cf6c864a2adc2b8acb5d0128edb923e87949fe41 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Mon, 16 Dec 2019 16:26:14 +0100 Subject: [PATCH] Vertx#close Future will not callback the handler - closes #3232 --- src/main/java/io/vertx/core/impl/VertxImpl.java | 3 ++- src/test/java/io/vertx/core/VertxTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/vertx/core/impl/VertxImpl.java b/src/main/java/io/vertx/core/impl/VertxImpl.java index c92f7a42a..f22f8b594 100644 --- a/src/main/java/io/vertx/core/impl/VertxImpl.java +++ b/src/main/java/io/vertx/core/impl/VertxImpl.java @@ -478,7 +478,8 @@ public class VertxImpl implements VertxInternal, MetricsProvider { @Override public Future close() { - Promise promise = getOrCreateContext().promise(); + // Create this promise purposely without a context because the close operation will close thread pools + Promise promise = Promise.promise(); close(promise); return promise.future(); } diff --git a/src/test/java/io/vertx/core/VertxTest.java b/src/test/java/io/vertx/core/VertxTest.java index 2f8975b21..bab1b1c07 100644 --- a/src/test/java/io/vertx/core/VertxTest.java +++ b/src/test/java/io/vertx/core/VertxTest.java @@ -100,4 +100,15 @@ public class VertxTest extends AsyncTestBase { }); await(); } + + @Test + public void testCloseFuture() throws Exception { + Vertx vertx = Vertx.vertx(); + Future fut = vertx.close(); + // Check that we can get a callback on the future as thread pools are closed by the operation + fut.onComplete(onSuccess(v -> { + testComplete(); + })); + await(); + } }