commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [collections] Uniform null-safe methods in CollectionUtils
Date Mon, 05 Jun 2017 10:44:29 GMT
Hello Bruno,

> Am 27.05.2017 um 15:40 schrieb Bruno P. Kinoshita <brunodepaulak@yahoo.com.br.INVALID>:
> 
> Hi,
> 
> COLLECTIONS-600 [1] received a pull request [2] to make a method in CollectionUtils null-safe.
Before merging it, I decided to check what was the current approach in this class for handling
null in methods.
> 
> COLLECTIONS-604 [3] contains the CSV file with the methods names and current behaviour.
TL;DR "Currently, there are 65 public methods in `CollectionUtils`. And 53 without the deprecated
ones. Out of these, 24 handle `null` arguments. The remaining methods throw a `NullPointerException`
(NPE) at some part of its code."
> 
> There are also cases where the javadocs suggest a NPE if any of the arguments is null,
but there are no if's checking if it is null, instead it relies on a call to a member of the
object to raise the NPE, or the intriguing case of CollectionUtils.isEmpty(null) which returns
true, and CollectionUtils.isFull(null) which throws NPE (even though there is a isNotEmpty,
I'd expect isEmpty and isFull to be in some way related and have similar behaviour).
> 
> Should we just work method per method and make it null-safe if necessary, or should we
define a common behaviour to all of its methods? I can see some advantages of the latter for
users, but am still not sure which approach to take here.

Nobody seems to have an opinion on this issue so you should start implementing your preference.

Regards,
Benedikt

> 
> Cheers
> Bruno
> 
> [1] https://issues.apache.org/jira/browse/COLLECTIONS-600
> [2] https://github.com/apache/commons-collections/pull/22
> [3] https://issues.apache.org/jira/browse/COLLECTIONS-604
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message