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

Modifying ArrayList.subList().subList() resets modCount of subList

    Details

      Backports

        Description

        When a sublist of a sublist is created, its modCount is copied from the root ArrayList, not the immediate parent.
        This means that modifying that 2nd-level sublist will reset the modCount of its parent, so it won't detect concurrent modifications to the root.

        Similar issue is happening with the sublist's iterator: When an iterator for an ArrayList.SubList is created, its expectedModCount is set to root.modCount (i.e. the modCount of the ArrayList), while it would be more accurate to set it to SubList.this.modCount (i.e. the modCount of the SubList).
        With the current implementation, if the root ArrayList is modified immediately before creating the SubList.iterator not via this SubList, the iterator will fail to detect the concurrent modification.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  igerasim Ivan Gerasimov (Inactive)
                  Reporter:
                  igerasim Ivan Gerasimov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: