[ 
https://issues.apache.org/jira/browse/CONFIGURATION-26?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13435884#comment-13435884
 ] 

Baris Acar commented on CONFIGURATION-26:
-----------------------------------------

Last updates on this issue were in 2007 - did anything happen?

I would argue that {{getString()}} should return the value from the property 
file _verbatim_ - not the first item in the list, but not concatenated either - 
I'm concerned concatenation could end up slightly changing the format, using 
the wrong delimiter, etc. (Ittay's suggestion of returning "the string 
representation of a List" is somewhat ambiguous - does he/she mean 
{{List.toString()}}? This may not be what's wanted).

What is the use case for having {{getString}} return the first item of a list 
anyway? I have to say as a newcomer to commons config, this is _very_ 
unexpected behaviour. If someone wants the first item of a list, surely they 
_know_ that and can just request {{config.getStringArray("foo")[0]}}, which is 
clear and explicit.

As it stands I don't appear to have a way to parse the following config 
meaningfully:
{code}
foo=hello, world! 
bar=first,second 
{code}
with foo as a string ("hello, world!") and bar as a list ({"first", "second"}).


                
> Consider returning a concatenation of the list properties with getString()
> --------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-26
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-26
>             Project: Commons Configuration
>          Issue Type: Bug
>            Reporter: Ittay Dror
>            Priority: Minor
>             Fix For: 2.0
>
>
> in AbstractConfiguration.resolveContainerStore (javadoc):
>   * Returns an object from the store described by the key. If the value is a
>   * List object, replace it with the first object in the list.
> but what if getProperty returns a List because this is the type of the 
> property? 
>  this code will silently grab the first elemen. I don't understand why. 
> Probably 
> the reason is that some class extending AbstractConfiguration returns List 
> for 
> properties. In this case I think the better approach is to have that class 
> return the first element instead, rather than returning the List and letting 
> AbstractConfiguration (which is used by many other implementations, including 
> outside of the configuration package) handle it

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to