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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: