Env properties not set when creating them via ConfigCache.getOrCreate
alexanderm2018 opened this issue · 5 comments
I have these two properties
@DefaultValue("${java.home}")
String javaHome();
@DefaultValue("${TARGET_ENV}")
String env();
if I use ConfigFactory.create I can access them
cfg = ConfigFactory.create(RestApiConfig.class, System.getProperties(), System.getenv());
cfg.env() returns value as expected
if I use ConfigCache.getOrCreate, I get empty string.
cfg = ConfigCache.getOrCreate(RestApiConfig.class, System.getProperties(), System.getenv());
cfg.evn() returns empty string
Expected to work the same.
@alexanderm2018 Can you create a unit test for this bug? (pull request)
where in your repo?
send me the path where I should add my test class
anywhere you want: just add a test case where you think it's appropriate and send me a pull request; so that I can have a look.
@alexanderm2018, are you sure that's the first time the application instantiates the cfg? The behavior of ConfigCache
is to keep the reference of the very first instance and return it whenever called again. https://github.com/lviggiano/owner/blob/master/owner/src/main/java/org/aeonbits/owner/ConfigCache.java#L88
Just created some tests for that exemplification.
cannot reproduce