From 58f2c881ba6ad04e9a8d7f918fbb04bfa75266cf Mon Sep 17 00:00:00 2001 From: zenios Date: Thu, 14 Nov 2019 00:25:01 +0200 Subject: [PATCH] =?UTF-8?q?Fixes=20incomplete=20promise=20when=20a=20child?= =?UTF-8?q?=20verticle=20could=20not=20be=20deployed=20=E2=80=A6=20(#3186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes incomplete promise when a child verticle could not be deployed because its parent has been undeployed Signed-off-by: zenios * Added tests Signed-off-by: zenios * Fail the promise after undeploy is completed Signed-off-by: zenios * Simplify test using onSuccess / onFailure Signed-off-by: zenios * Use await / testComplete instead of CountDownLatch Signed-off-by: zenios --- .../io/vertx/core/impl/DeploymentManager.java | 2 +- src/test/java/io/vertx/core/DeploymentTest.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/vertx/core/impl/DeploymentManager.java b/src/main/java/io/vertx/core/impl/DeploymentManager.java index 775727748..48c7162c7 100644 --- a/src/main/java/io/vertx/core/impl/DeploymentManager.java +++ b/src/main/java/io/vertx/core/impl/DeploymentManager.java @@ -463,7 +463,7 @@ public class DeploymentManager { deployment.child = true; } else { // Orphan - deployment.undeploy(null); + deployment.undeploy(event -> promise.fail("Verticle deployment failed.Could not be added as child of parent verticle")); return; } } diff --git a/src/test/java/io/vertx/core/DeploymentTest.java b/src/test/java/io/vertx/core/DeploymentTest.java index 4d7f74d4b..0a825f419 100644 --- a/src/test/java/io/vertx/core/DeploymentTest.java +++ b/src/test/java/io/vertx/core/DeploymentTest.java @@ -1234,6 +1234,22 @@ public class DeploymentTest extends VertxTestBase { vertx = null; } + @Test + public void testDeployChildOnParentUndeploy() { + class ParentVerticle extends AbstractVerticle { + @Override + public void stop(Promise stopPromise) { + vertx.deployVerticle(ChildVerticle.class.getName()) + .mapEmpty() + .setHandler(stopPromise); + } + } + + vertx.deployVerticle(new ParentVerticle(), onSuccess(id -> + vertx.undeploy(id, onFailure(u -> testComplete())))); + await(); + } + @Test public void testUndeployAllFailureInUndeploy() throws Exception { int numVerticles = 10;