vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

java.lang.IllegalStateException: Result is already complete: succeeded #9

Closed nimo23 closed 7 years ago

nimo23 commented 7 years ago

I use vertx 3.4.1.

I want to load config.json from file-system within a start-method of a vertical-instance:

ConfigStoreOptions configFile = new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("json")
                  .setConfig(new JsonObject().put("path", "src/main/resources/config.json"));

          ConfigRetrieverOptions options = new ConfigRetrieverOptions().addStore(configFile);
          ConfigRetriever retriever = ConfigRetriever.create(vertx, options);

          retriever.getConfig(ar -> {
              if (ar.failed()) {
                  log.warn("Failed to retrieve the configuration");
              } else {
                  JsonObject config = ar.result();
                  log.info(config.getString("http.port"));
              }
            });

However, I get this stacktrace:

[INFO] 16:59:40.774 | vert.x-eventloop-thread-0 | ContextImpl | 343 | Unhandled exception
[INFO] java.lang.IllegalStateException: Result is already complete: succeeded
[INFO]  at io.vertx.core.impl.FutureImpl.fail(FutureImpl.java:121) ~[vertx-core-3.4.1.jar:?]
[INFO]  at io.vertx.config.impl.ConfigRetrieverImpl.lambda$null$7(ConfigRetrieverImpl.java:166) ~[vertx-config-3.4.1.jar:?]
[INFO]  at io.vertx.config.impl.ConfigurationProvider.lambda$null$0(ConfigurationProvider.java:41) ~[vertx-config-3.4.1.jar:?]
[INFO]  at io.vertx.config.impl.spi.JsonProcessor.process(JsonProcessor.java:27) ~[vertx-config-3.4.1.jar:?]
[INFO]  at io.vertx.config.impl.ConfigurationProvider.lambda$get$1(ConfigurationProvider.java:39) ~[vertx-config-3.4.1.jar:?]
[INFO]  at io.vertx.core.impl.FutureImpl.checkCallHandler(FutureImpl.java:188) ~[vertx-core-3.4.1.jar:?]
[INFO]  at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:100) ~[vertx-core-3.4.1.jar:?]
[INFO]  at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:287) ~[vertx-core-3.4.1.jar:?]
[INFO]  at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337) ~[vertx-core-3.4.1.jar:?]
[INFO]  at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-common-4.1.8.Final.jar:4.1.8.Final]
[INFO]  at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) [netty-common-4.1.8.Final.jar:4.1.8.Final]
[INFO]  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445) [netty-transport-4.1.8.Final.jar:4.1.8.Final]
[INFO]  at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.8.Final.jar:4.1.8.Final]
[INFO]  at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]

Is this my fault?

cescoffier commented 7 years ago

Shouldn't you read the "http.port" property as an integer and not a String. It causes a class cast exception.

nimo23 commented 7 years ago

yes, you are right. This was my fault. Within the stacktrace there was no sign for a class cast exception..

cescoffier commented 7 years ago

Yes, I'm actually chasing why.

cescoffier commented 7 years ago

(don't close the issue, I will close it when I've the answer)