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

Expanded property keys are not reported by Accessible methods #230

Open
ysmartin opened this issue May 15, 2018 · 1 comment
Open

Expanded property keys are not reported by Accessible methods #230

ysmartin opened this issue May 15, 2018 · 1 comment

Comments

@ysmartin
Copy link
Contributor

If I try to use the expansion method
E.g. if I define

public interface MyProjectConfig extends Config, Accessible {
	@Key("myproject.prefix")
	@DefaultValue("myproject")
	String configPrefix();

	@Key("${myproject.prefix}" + ".debug")
	@DefaultValue("false")
	boolean debug();
}

And elsewhere I try to load the config and use the Accessible methods

    config = ConfigCache.getOrCreate(MyProjectConfig.class);
    // Log all the properties using Accessible.store
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    config.store(new PrintStream(out), "--- loaded properties ---");
    out.flush();
    log.info(out);

    // Again, using Accessible.list
    out = new ByteArrayOutputStream();
    config.list(new PrintStream(out));
    out.flush();			
    log.info(out);

    // Now get property names
    log.info("Property names:"  + config.propertyNames());

They I get duplicate properties, ones with the values loaded from the external files and other with the default values, but without any expansion applied to the keys:

myproject.debug=true
${myproject.prefix}.debug=true

etc.
Nonetheless, when using the config interface methods, it returns the appropriate values:

    log.info("Debug mode: " + config.debug());

2018-05-15 18:11:18,251 INFO [...] Debug mode: true

@lviggiano
Copy link
Collaborator

Hi.

The expansion is resolved at run time, when you call the method. This is why you don't see it in properties lists.

I think it's not a wrong behavior: it dumps its internal structure, and to me it looks consistent as behavior.

Luigi.

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

2 participants