Open mschaefers opened 10 years ago
Thanks for the report. Would you mind writing up a quick unit test that fails for what you expect to happen?
Hi Jason, I wrote a small TestApplication including a JUnit Test, available at https://github.com/mschaefers/hocon-bug
Steps to reproduce:
check out repository :) run ./gradlew test
one test without substitution will pass, the other one with substitution will lead to a NullPointerException that currently hides the ConfigException I opened this Issue for.
For The NullPointerException I will send you a pull request shortly. Thanks for your support, Michael
I'm seeing something similar with an environment variable substitution:
{ name: "configuredName" name: ${?ENVIRONMENT_VARIABLE_NAME} }
hides the following ConfigException: com.typesafe.config.ConfigException$NotResolved: called valueType() on value with unresolved substitutions, need to Config#resolve() first, see API docs at com.typesafe.config.impl.ConfigDelayedMerge.valueType(ConfigDelayedMerge.java:46) at com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser.asJsonToken(HoconTreeTraversingParser.java:85) at com.jasonclawson.jackson.dataformat.hocon.HoconNodeCursor.asJsonToken(HoconNodeCursor.java:54) at com.jasonclawson.jackson.dataformat.hocon.HoconNodeCursor$Object.nextToken(HoconNodeCursor.java:193) at com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser.nextToken(HoconTreeTraversingParser.java:178) at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:221) at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:62) at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:14) at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3534) at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1978) at io.dropwizard.configuration.HoconConfigurationFactory.build(HoconConfigurationFactory.java:83) at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:114) at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:63) at io.dropwizard.cli.Cli.run(Cli.java:70) at io.dropwizard.Application.run(Application.java:73) at com.example.TestApplication.main(TestApplication.java:11)
ok for the substitution you just need a more recent version of your hocon-jackson-dataformat library (1.1.0 appears to work properly)
I am currently using the dropwizardry-config-hocon bundle to parse a HOCON configuration.
While parsing
works like a charm, substituting values does not. This example
leads to a
ConfigException
sayingAm I missing something here or is value substitution not supported?