-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 9
-
Component/s: core-libs
-
b112
-
Verified
The spliterator created by ArrayList.subList() should be late-binding, but it's not. Here's simple test:
List<Integer> list = new ArrayList<>(Arrays.asList(1,2,3,4)).subList(0, 3);
Stream<Integer> s = list.stream();
list.add(5);
s.findFirst();
--> Exception in thread "main" java.util.ConcurrentModificationException
This works correctly if ArrayList is replaced with LinkedList or Vector.
List<Integer> list = new ArrayList<>(Arrays.asList(1,2,3,4)).subList(0, 3);
Stream<Integer> s = list.stream();
list.add(5);
s.findFirst();
--> Exception in thread "main" java.util.ConcurrentModificationException
This works correctly if ArrayList is replaced with LinkedList or Vector.