Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOCON substitution not working #1

Open
mschaefers opened this issue Oct 23, 2014 · 4 comments
Open

HOCON substitution not working #1

mschaefers opened this issue Oct 23, 2014 · 4 comments

Comments

@mschaefers
Copy link

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
Copy link
Owner

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

@mschaefers
Copy link
Author

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants