-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
8u11
Specification
http://docs.oracle.com/javase/8/docs/api/java/util/List.html#subList-int-int-
says:
"Throws:
IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex)"
However it doesn't happen for some lists, please see the following code:
---
CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
List<Integer> newList = list.subList(1, list.size() - 1);
int fromIndex = 2;
int toIndex = 1;
newList.subList(fromIndex, toIndex);
---
No exception will be thrown though fromIndex > toIndex.
The following new JCK8a test will be failing due to this:
api/java_util/concurrent/CopyOnWriteArrayList/index.html#CopyOnWriteArrayList[testSubList3_IndexOutOfBoundsException]
The problem is seen with JDK8, JDK8u5
http://docs.oracle.com/javase/8/docs/api/java/util/List.html#subList-int-int-
says:
"Throws:
IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex)"
However it doesn't happen for some lists, please see the following code:
---
CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
List<Integer> newList = list.subList(1, list.size() - 1);
int fromIndex = 2;
int toIndex = 1;
newList.subList(fromIndex, toIndex);
---
No exception will be thrown though fromIndex > toIndex.
The following new JCK8a test will be failing due to this:
api/java_util/concurrent/CopyOnWriteArrayList/index.html#CopyOnWriteArrayList[testSubList3_IndexOutOfBoundsException]
The problem is seen with JDK8, JDK8u5
- duplicates
-
JDK-8011645 CopyOnWriteArrayList.COWSubList.subList does not validate range properly
-
- Closed
-