-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Allow specifying unit type of configuration property when injected via constructor #21746
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
Allow specifying unit type of configuration property when injected via constructor #21746
Conversation
65a6adb
to
a428fd6
Compare
…a constructor spring-projects#20892 Allow specifying unit type of configuration property when injected via constructor spring-projects#20892 ... ...
a428fd6
to
6d41a69
Compare
Before merging this we should double check that the metadata is generated with the correct unit. |
The unit seems to be missing from the metadata. For example: {
"name": "test.size",
"type": "org.springframework.util.unit.DataSize",
"sourceType": "com.example.demo.ConstructorParameterWithConversionProperties",
"defaultValue": "3"
} The above is from a properties class based on the one that's added to the tests in this PR. The constructor argument is declared as |
I would have expected that indeed. We need to update this support to lookup the unit annotation on others places. |
Looking at the metadata and how values are extracted, this applies using the code that's written for the field initialization something like, Allowing the unit on the constructor parameter makes such construct possible so it'd be legitimate for users to expect the other variant to work. It means that the annotation processor has to look for those 3 additional annotations too and handle it only if the default value is an integer. I wonder if we want that extra complexity. |
We've discussed this and concluded that having |
Allow specifying unit type of configuration property when injected via constructor #20892