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.

Clarify when defaultValue is used on ConfigProperty

See original GitHub issue

Clarify 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 assign null.

  • 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
Emily-Jiangcommented, Mar 16, 2021

@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.

1reaction
Emily-Jiangcommented, Sep 30, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[jboss-jira] [JBoss JIRA] (WFWIP-55) Default value defined on ...
... I'll check with MicroProfile Config to clarify the behaviour of array and collections in the absence of configured and default value.
Read more >
Provide empty string to Quarkus as the default value for an ...
I tried to add the defaultValue = "" property to @ConfigProperty but it does not change anything. I tried to add a colon:...
Read more >
Configuration for MicroProfile
Use @ConfigProperty to provide a default value. Use Optional<T> or OptionalInt , OptionalDouble , OptionalLong as the type.
Read more >
Default value set in target config property returns null in LWC JS
I am trying to set a @track variable in my LWC JS using default value in target config property defined in -meta.xml.
Read more >
Configure MicroProfile with Azure Key Vault - Microsoft Learn
@Inject @ConfigProperty(name = "key-name", defaultValue = "Unknown") ... We'll use the Azure CLI to create the Azure Key Vault resource and ...
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