Async undeploy won't report exception by the verticle with promise complete - closes #3075

This commit is contained in:
Julien Viet
2019-08-19 12:12:50 +02:00
parent d7fb03b01f
commit f13add9017
2 changed files with 27 additions and 1 deletions

View File

@@ -668,7 +668,9 @@ public class DeploymentManager {
try {
verticleHolder.verticle.stop(stopPromise);
} catch (Throwable t) {
stopPromise.fail(t);
if (!stopPromise.tryFail(t)) {
undeployingContext.reportException(t);
}
}
});
}

View File

@@ -877,6 +877,7 @@ public class DeploymentTest extends VertxTestBase {
await();
}
@Test
public void testAsyncUndeployCalledSynchronously() throws Exception {
MyAsyncVerticle verticle = new MyAsyncVerticle(f -> f.complete(null), f -> f.complete(null));
@@ -943,6 +944,29 @@ public class DeploymentTest extends VertxTestBase {
await();
}
@Test
public void testAsyncUndeployFailsAfterSuccess() {
waitFor(2);
Verticle verticle = new AbstractVerticle() {
@Override
public void stop(Promise<Void> stopPromise) throws Exception {
stopPromise.complete();
throw new Exception();
}
};
Context ctx = vertx.getOrCreateContext();
ctx.runOnContext(v1 -> {
vertx.deployVerticle(verticle, onSuccess(id -> {
ctx.exceptionHandler(err -> {
complete();
});
vertx.undeploy(id, onSuccess(v2 -> {
complete();
}));
}));
});
await();
}
@Test
public void testChildUndeployedDirectly() throws Exception {
Verticle parent = new AbstractVerticle() {