I did use ConfigProvider.
getConfig() as a workaround as was suggested however now that class can't be unit tested.
Also just some feedback on the
ConfigProvider.getConfig().getValue (String propertyName, Class<T> propertyType) operation.
It's not very friendly to use as my response type is List<String>. So I had to change to this:
ConfigProvider.getConfig().getValue("app.response-headers", String[].class);
But that array can be empty and if that happens it throws NoSuchElementException...but it does exist...just empty.
So I have to do this:
String[] responseHeaders = new String[0];
try {
responseHeaders = ConfigProvider.getConfig().getValue(
"app.response-headers" , String[].class);
} catch (Exception ignored) {
}
Lot of code just to read one property. Is getOptionalValue() to help solve this? Does it catch the exception? Even if actually does not exist? I can't think of a good reason to ever throw...just want whatever exists if any. Having a default value is useful but I don't see that option.
Thanks,
-Dave