Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8148748

ArrayList.subList().spliterator() is not late-binding

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • core-libs

      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.

            tvaleev Tagir Valeev
            tvaleev Tagir Valeev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: