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. 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-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org