[ 
https://issues.apache.org/jira/browse/CONFIGURATION-846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved CONFIGURATION-846.
-------------------------------------------
    Fix Version/s: 2.10.2
       Resolution: Fixed

> Unable to load multivalued configurations into Spring using 
> ConfigurationPropertySource
> ---------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-846
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-846
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 2.10.0, 2.10.1
>            Reporter: Tim Donohue
>            Priority: Minor
>             Fix For: 2.10.2
>
>
> We've run into an odd bug when using Commons Configuration v2 + Spring Boot 
> which I _believe_ is caused by changes in the PR 
> [https://github.com/apache/commons-configuration/pull/309] to address 
> https://issues.apache.org/jira/browse/CONFIGURATION-834.   
> During a routine upgrade from Commons Configuration v2.9.0 to v2.10.1, we 
> discovered that our multivalued configurations (i.e. an array or list of 
> values) were only loading the *first value* into Spring.  In other words, it 
> seems to no longer be possible to load multivalued configurations into Spring 
> Beans via something like this:
> {{@Value("${some.multivalued.prop}")}}
> {{String[] myMultivaluedVariable;}}
> I could be wrong, but I _believe_ it may be caused by the [change from  
> `getProperty()` to `getString()` in PR 
> 309|https://github.com/apache/commons-configuration/pull/309/files#diff-2f481434a16d50ce9df3af48f9e72fc8872050b0e8d1614fcd7420a8779db283R52],
>  because `getString()` is [documented to only return the *first value* in a 
> list of 
> values|https://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#List_handling]
> {quote}Of interest is also the last line of the example fragment. Here the 
> `getString()` method is called for a property that has multiple values. This 
> call will return the first value of the list.
> {quote}
> I don't know of the proper solution to this issue. But I can confirm that 
> v2.9.0 works properly for multivalued configurations, but both v2.10.0 and 
> v2.10.1 do not (in both those versions we are seeing only the first value 
> loaded into Spring for multivalued configurations).
> For our purposes, we are looking to create a custom 
> ConfigurationPropertySource to workaround this issue in our codebase.  
> However, ideally, it'd be better to ensure the default 
> ConfigurationPropertySource is still able to handle multi-valued 
> configurations.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to