简体   繁体   English

Vertx 测试关于部署 Verticle 的上下文问题

[英]Vertx test on context issues deploying verticle

So this is a bit of a sneaky one, it doesn't occur 100% of the time, but this is the situation:所以这有点偷偷摸摸,它不会100%发生,但情况是这样的:

I created a JUnit integration class, declared a Rule to run on context, then i extract the vertx object from the rule.我创建了一个JUnit集成类,声明了一个在上下文上运行的Rule ,然后我从规则中提取了vertx对象。 Then i deploy new verticles to the vertx , and if try to deploy more than ~3-4 verticles i get this for each verticle:然后我将新的vertx部署到vertx ,如果尝试部署超过 3-4 个vertx ,我会为每个 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();另一件事要提到的是,如果我改变Vertx vertx = rule.vertx(); with Vertx vertx = Vertx.vertx();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?这是一个问题吗?

Are you using version 3.3.3.您使用的是 3.3.3 版本吗? You might be hitting this issue: https://github.com/eclipse/vert.x/issues/1625 (fixed in master)您可能会遇到此问题: https : //github.com/eclipse/vert.x/issues/1625 (已在 master 中修复)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM