commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Krkoska (JIRA)" <>
Subject [jira] Created: (COLLECTIONS-331) CollatingIterator NPE when Comparator is null
Date Wed, 24 Jun 2009 14:33:07 GMT
CollatingIterator NPE when Comparator is null

                 Key: COLLECTIONS-331
             Project: Commons Collections
          Issue Type: Bug
          Components: Iterator
    Affects Versions: 3.2
            Reporter: Michael Krkoska
            Priority: Minor

Run the attached Test against commons-collections-3.2.1. While the JavaDoc for CollatingIterator

{{@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 (,leastObject) < 0) { ...

could be replaced with

int c = comparator==null?((Comparable)curObject).compareTo(leastObject),leastObject);
if (c < 0) { ...

The workaround is to provide a comparator, of course.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message