-
Notifications
You must be signed in to change notification settings - Fork 116
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
Need a way to specify empty list/array in microprofile-config.properties #397
Comments
|
An Optional which stores a Collection which it indicates is not null but that has no elements. Using converters. |
@hutchig I understand that a component can write its own Converter to interpret a value as an empty array/list/collection, although that doesn't really address the problem of how the end user should expect to disambiguate between String[] { "" } and String[] {} in microprofile-config.properties. I was expecting that MicroProfile Config would standardize some sort of syntax for this. It looks like you have an escape character, |
Alternatively, the MicroProfile spec that I'm working on could document that the way for users to specify empty array is to specify empty string in MP Config. If that's the solution, I'm fine with it. I just want to first be sure that I'm truly following the guidance of MP Config rather than going off on my own and defining something non-standard that will lack consistency with other MicroProfile specifications. |
It's true that the spec doesn't say how an empty value is converted to an array. It should be clarified and also assured by a test. I suggest that an empty value is converted to an empty array, i.e. an array with 0 elements. Additionally, we can also specify an edge case for an array with a single empty string which would be created if the value is just the escape character ( This should be in line with how other converters work. A string converter represents an empty value as an empty string. An array then should represent it as an empty array. For example: We could also do it the other way around and specify that an empty value results in an array with a single empty string element, while to specify an empty array people would have to use |
By the way, I think that the spec is wrong in the example:
|
@OndroMih iirc you can't write |
I've opened #407 to specify how the Config API handles config property with empty value as well as a TCK test to verify these assertions. Tl;DR: a config property with an empty value results in an empty "thing" (e.g. an empty string or an empty collection) |
@OndroMih Can you elaborate a bit more on why you think it is wrong. |
Related to #531. |
The MicroProfile Config spec currently specifies that Array Converters are built in, and provides examples of how to configure values that are multiple array elements (delimit by
,
). However, it does not appear to document how to configure a value that is an empty array.On one implementation, I tried out specifying an empty value, like this,
but it ended up with a value that is an array of size 1 containing the empty string.
I also tried out specifying the value as the value of the org.eclipse.microprofile.config.inject.ConfigProperty.UNCONFIGURED_VALUE constant (lacks documentation, so not sure if this is proper usage. Also, it seems to have two different values depending on which version of the ConfigProperty class is used),
but this resulted in a size 1 array containing the specified constant value.
It's likely the above behavior is to be expected, but the requirement to be able to specify an empty list also seems valid. In another MicroProfile spec, we are utilizing MicroProfile Config to allow the user to supply configuration property values, some of which are lists/arrays. It ought to be possible for MicroProfile Config to have a standard way to set these list/array values to empty.
The text was updated successfully, but these errors were encountered: