jclawson / dropwizardry

Makes dropwizard even more awesome
Apache License 2.0
9 stars 5 forks source link

HOCON substitution not working #1

Open mschaefers opened 10 years ago

mschaefers commented 10 years ago

I am currently using the dropwizardry-config-hocon bundle to parse a HOCON configuration.

While parsing

   foo = X
   bar = Y

works like a charm, substituting values does not. This example

 foo = X
 bar = ${foo}

leads to a ConfigException saying

need to Config#resolve(), see the API docs for Config#resolve(); substitution not resolved: ConfigReference(${foo})

Am I missing something here or is value substitution not supported?

jclawson commented 10 years ago

Thanks for the report. Would you mind writing up a quick unit test that fails for what you expect to happen?

mschaefers commented 10 years ago

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

josephlbarnett commented 9 years ago

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)

josephlbarnett commented 9 years ago

ok for the substitution you just need a more recent version of your hocon-jackson-dataformat library (1.1.0 appears to work properly)