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

@ConfigProperties system doesn't allow using @ConfigProperty on class fields, only on interface methods #11367

Closed
Ladicek opened this issue Aug 13, 2020 · 4 comments · Fixed by #11663
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@Ladicek
Copy link
Contributor

Ladicek commented Aug 13, 2020

Describe the bug
If I use the @ConfigProperties annotation on an interface, I can customize config property names for the interface methods using the @ConfigProperty annotation.

I expect to be able to do the same for a class annotated with @ConfigProperties, but ClassConfigPropertiesUtil.populateConfigObject says '@ConfigProperty' is ignored when added to a field of a class annotated with '@ConfigProperties'.

This is not documented and is certainly unexpected. I don't even call this an enhancement proposal, but a bug -- I consider feature parity between @ConfigProperties classes and interfaces a natural expectation.

CC @geoand, as @mkouba said he's the author of the @ConfigProperties system :-)

@geoand
Copy link
Contributor

geoand commented Aug 13, 2020

Yeah, this was intentional, but I don't remember why.

I'll need to go think about it again when I get back

@geoand
Copy link
Contributor

geoand commented Aug 24, 2020

I remember why I did this:

Basically I didn't want @ConfigProperty.defaultValue to come into play when using classes, as the default value should just be set in code.
@Ladicek I assume that you want to be able to customize the field names, right? If so, then I guess we can relax the constraint and just disallow defaultValue. WDYT?

@Ladicek
Copy link
Contributor Author

Ladicek commented Aug 24, 2020

For complex types (with Converters), expressing default values in code doesn't necessarily have to be possible, so I'd say defaultValue should work as well. (And if it's set, then it should take precedence.) But yes, when I stumbled upon this, I was mainly after customizing the configuration key.

@geoand
Copy link
Contributor

geoand commented Aug 24, 2020

OK, I'll add this to the list of things I need to do (the name part at least) :)

geoand added a commit to geoand/quarkus that referenced this issue Aug 27, 2020
geoand added a commit that referenced this issue Aug 27, 2020
Allow the use of @ConfigProperty name with @ConfigProperties class
@gsmet gsmet added this to the 1.8.0.CR1 milestone Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants