CDI @ConfigProperty default value consistency should be enforced
See original GitHub issueIf the same configuration property is given more than once via the @ConfigProperty
annotation, they should be enforced to have the same default value string, or else an error should result.
This is a necessary prerequisite to #405; if multiple default values are allowed for a given property, then it becomes impossible to define which value would be returned for an expression string which references that property.
The specification text for @ConfigProperty
should be updated to this effect.
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (22 by maintainers)
Top Results From Across the Web
ConfigProperty (MicroProfile Config API)
A further recommendation is to use the built in META-INF/microprofile-config.properties file mechanism to provide default values inside an Application.
Read more >Showing posts for tag "osgi" - frostillic.us
Here, I'm making use of the fact that a default provider looks up Java system properties, so I could just get it working...
Read more >First Step | JEE Microservices with MicroProfile-Config
MicroProfile-Config allows us to provide configurations to our ... Custom configuration sources can be implemented as well and will be ...
Read more >Jeff Mesnil — Weblog
@Inject @ConfigProperty(name = "app.timeout", defaultValue = "5000") long ... interface that can be implemented by an application developer.
Read more >Server Developer Guide
For example to ignore the Accept-Language request header, a custom implementation could extend the default provider, override it's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Additionally, we can consider to add an API to provide the default values and deprecate
@ConfigProperty#defaultValue
. But that can be done in a separate issue / PR in 2.1 or forward.After discussing this in yesterdays weekly meeting I first grasped the entirety of this proposal. I try to summarised it again in my own words so that it might help others in getting an understanding.
The issue: The same property can be injected multiple times using
@ConfigProperty
where each occurrence could state a differentdefaultValue
. Looking at each injection point alone this is fine. When looking at it in context of other features (caching, var expansion, …) the ambiguity causes issues.The proposal is this: On deployment CDI
defaultValue
for any configuration property use the same default value or otherwise throws an exceptiondefaultValue
from annotations generally available by virtually putting them in a map and wrapping that map in a newConfigSource
with lowest priority so that these defaults become effective even for lookups where the default isn’t directly supplied.The goal is to make defaults apply consistently independent of where and how the lookup was made.