So this is a bit of a sneaky one, it doesn't occur 100% of the time, but this is the situation:
I created a `JUnit` integration class, declared a `Rule` to run on context, then i extract the `vertx` object from the rule. Then i deploy new verticles to the `vertx`, and if try to deploy more than ~3-4 verticles i get this for each verticle:
Jan 09, 2017 2:43:33 PM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
java.lang.IllegalStateException: Result is already complete: succeeded
at io.vertx.core.impl.FutureImpl.checkComplete(FutureImpl.java:164)
at io.vertx.core.impl.FutureImpl.complete(FutureImpl.java:108)
at io.vertx.core.impl.FutureImpl.handle(FutureImpl.java:135)
at io.vertx.core.impl.FutureImpl.handle(FutureImpl.java:23)
at io.vertx.core.eventbus.impl.EventBusImpl.lambda$callCompletionHandlerAsync$2(EventBusImpl.java:340)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:316)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:418)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:440)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at java.lang.Thread.run(Thread.java:745)
The code causing this issue looks like that:
@RunWith(VertxUnitRunner.class)
public class VertxTest {
@Rule
public RunTestOnContext rule = new RunTestOnContext(Vertx::vertx);
@Test
public void testLinearExecution(TestContext context) {
Vertx vertx = rule.vertx();
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
}
}
It might depend on the machine running it, but my guess is that if it doesn't reproduce, add more of those guys to make it more probable:
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
this.vertx.eventBus().consumer("bla", event -> {});
}
});
Another thing to mention is that if i change `Vertx vertx = rule.vertx();` with `Vertx vertx = Vertx.vertx();`, i get the warning message to console, but the problem goes away.
So, am i doing something wrong? Is it an issue?