question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CDI @ConfigProperty default value consistency should be enforced

See original GitHub issue

If 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:open
  • Created 4 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
radcortezcommented, Jul 17, 2020

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.

1reaction
jbeecommented, Jul 17, 2020

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 different defaultValue. 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

  1. verifies that all defaultValue for any configuration property use the same default value or otherwise throws an exception
  2. makes the defaultValue from annotations generally available by virtually putting them in a map and wrapping that map in a new ConfigSource 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found