Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.2
-
None
Description
Run the attached Test against commons-collections-3.2.1. While the JavaDoc for CollatingIterator claims
@param comp the comparator to use to sort, or null to use natural sort order
the test fails, because the comparator is null.
Fixing this requires a change in org.apache.commons.collections.iterators.CollatingIterator.least():
if (comparator.compare(curObject,leastObject) < 0) { ...
could be replaced with
int c = comparator==null?((Comparable)curObject).compareTo(leastObject):comparator.compare(curObject,leastObject); if (c < 0) { ...
The workaround is to provide a comparator, of course.