-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Empty property in application.properties throw exception by injecting with @ConfigProperty eaven with defaultValue #2765
Comments
I think this is and should be intended. If you want a possible empty Property you can make myProperty an Optional |
I personally think that is should be allowed (and opened #2766) for it. Lets see what others think. |
@dmlloyd what's the status of the discussion in MP Config regarding this one? |
Ongoing. I would say that 50%+ of the weekly meetings have been cancelled in the past few months so progress has been slow. What I'm thinking is that the policy should be that primitives (other than |
Can SRye or Quarkus detect that the property is present, but empty ? |
There is no functional difference between empty and missing-without-default. Perhaps a better message would be "Value not present for property x". |
+1 |
Personally I think empty values should be allowed as it may be an intended value. |
If you want to allow empty values, use |
I personally hate this behavior. There is IMO a big difference between an absent property and a string property with an empty string as its value. Besides… although I understand that using |
It's the best we can do within the limits of the Microprofile-based configuration framework. Within that framework, an empty value is used to delete a lower-priority configuration value. It's a tradeoff: either there's no good way to represent a present-but-empty string (like today), or there's no good way to explicitly delete a value. The former problem mostly affects extension developers and configuration consumers, whereas the latter problem mostly affects people writing and reading configurations. In the end, the latter group was considered to be more important. That said, in retrospect, I think we should not have based our configuration system on Microprofile Config. That was a decision I made, but in hindsight I think it was a bad one. Had we based configuration on a more capable structured format, we probably wouldn't have had to make this particular tradeoff at all, while likely still being able to support users of Microprofile Config at an API level. In the future maybe we'll get a chance to revisit this design. |
Using Optional along with @ConfigProperty in a JAX-RS provider gives a warning:
But |
Add an empty property in application.properties
my.empty.property=
Inject property
@Inject @ConfigProperty(name = "my.empty.property") protected String myProperty = null;
Exception
javax.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: my.empty.property
The text was updated successfully, but these errors were encountered: