[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-user
Subject:    Re: [configuration2] Mismatch between getList doc and implementation
From:       Roman Zaynetdinov <roman.zaynetdinov () lekane ! com>
Date:       2021-02-16 12:00:19
Message-ID: CAOoCOReoE3a7txhG-5QVd_Gpui3c5KYroDWv-DkcTJ=ewkqQAA () mail ! gmail ! com
[Download RAW message or body]


Hi Gary,

I somehow didn't get your response in my email so responding to my own
message instead.

I have found the tests for this case here
https://github.com/apache/commons-configuration/blob/master/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationBasicFeatures.java#L898-L907
 Sadly for me it means that the method should be returning null. I was
hoping otherwise...

Changed doc in https://github.com/apache/commons-configuration/pull/100

- Roman

> You can try the change and see if it breaks any existing tests. Feel free
> to create a PR even if it just to make the Javadoc match the code. I've
not
> studied this part of the code in a while, so maybe someone else can opine.
> 
> Gary

On Fri, 12 Feb 2021 at 15:58, Roman Zaynetdinov <
roman.zaynetdinov@lekane.com> wrote:

> Hi,
> 
> I am switching to commons-configuration2 and trying to use typed getList
> method. I have noticed that javadoc doesn't correspond to the actual
> implementation.
> 
> ImmutableConfiguration.java:
> 
> /**
> * Gets a list of typed objects associated with the given configuration key
> * returning an empty list if the key doesn't map to an existing object.
> * ...
> */
> <T> List<T> getList(Class<T> cls, String key);
> 
> But implementation uses null as a default value.
> AbstractConfiguration.java:
> 
> public <T> List<T> getList(final Class<T> cls, final String key)
> {
> return getList(cls, key, null);
> }
> 
> Should it use new ArrayList<>() instead of null? Similar to untyped
> getList method?
> 
> - Roman
> 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic