Clarify when defaultValue is used on ConfigProperty
See original GitHub issueClarify when defaultValue is used
@ConfigProperty(name="my.property", defaultValue="123") int myProp;
In the javadoc of ConfigProperty
, it has the following:
The default value if the configured property value does not exist.
What if in a config source, the following config property is defined.
my.property=abc
.
Normally you will get IllegalArgumentException if the converter throws that. However, what if a converter did not throw an exception, it returns null
. Will defaultValue
or null
be assigned to the variable?
-
Option 1: defaultValue is not used and
null
-> myProp. Add a tck to verify this. Pros: honour the converter. In this way, converter has an option to assignnull
. -
Option 2: defaultValue is used. Javadoc needs to be updated to say: if converter return
null
, this value will be used. Pros: non null is returned. Cons: behaviour change. Not possible to return a null. Could be confusing if a property is defined with a value and the defaultValue is still used.
Thoughts?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top GitHub Comments
@Joseph-Cass Please open a new issue if further discussion is needed as this issue was closed and released. Any further discussions might confuse people.
I also prefer option 1 for the same reason @radcortez mentioned besides there is no behaviour change. I’ll create a TCK to try the option 1 first to see whether we hit any issues.