Issue Details (XML | Word | Printable)

Key: COLLECTIONS-230
Type: Wish Wish
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Henri Yandell
Reporter: Stepan Koltsov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Collections

CollectionUtils.size(null) should return 0

Created: 29/Oct/06 11:30 PM   Updated: 17/May/08 03:24 PM
Return to search
Component/s: None
Affects Version/s: 3.2
Fix Version/s: 4.0

Time Tracking:
Not Specified

Issue Links:
Dependants
 
Reference
 

Resolution Date: 20/Aug/07 04:12 PM


 Description  « Hide
Hello,

CollectionUtils.size(null) currently throws IllegalArgumentException("Unsupported object type: null"). I think CollectionUtils.size(null) should return 0.

Why?

The aim of library is to minimize the amount of code that uses this library. In my experience, in the most cases null collections can be threated as as zero-length. Current behavior causes the need of many trivial null-checks.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell added a comment - 15/Aug/07 05:28 AM
Sounds good to me. Any reasons not to?

Stephen Colebourne added a comment - 17/Aug/07 12:46 PM
+1

Henri Yandell added a comment - 20/Aug/07 04:12 PM
Done - there was a unit test that was testing that an IllegalArgumentException was thrown, so I removed that.