RFR [9] 8011645: CopyOnWriteArrayList.COWSubList.subList does not validate range properly

Paul Sandoz paul.sandoz at oracle.com
Fri Jan 31 17:05:48 UTC 2014


On Jan 31, 2014, at 5:23 PM, Chris Hegarty <chris.hegarty at oracle.com> wrote:
> Trivial change to CopyOnWriteArrayList.COWSubList.subList to catch the case where the fromIndex is greater that the toIndex.
> 
> http://cr.openjdk.java.net/~chegar/8011645/webrev.00/webrev/
> 

Looks ok to me.

--

Shame it's awkward to share this code from ArrayList:

    static void subListRangeCheck(int fromIndex, int toIndex, int size) {
        if (fromIndex < 0)
            throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
        if (toIndex > size)
            throw new IndexOutOfBoundsException("toIndex = " + toIndex);
        if (fromIndex > toIndex)
            throw new IllegalArgumentException("fromIndex(" + fromIndex +
                                               ") > toIndex(" + toIndex + ")");
    }

Paul.


More information about the core-libs-dev mailing list