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

CopyOnWriteArrayList subList needs more synchronization

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None

      Description

      Looking at CopyOnWriteArrayList.COWSubList, I see some methods that should have more synchronization:

      remove(Object o)

      void forEach(Consumer<? super E> action)
       array and indices must be read under lock, although elements themselves can be processed outside of lock!

      Spliterator<E> spliterator()
       Similarly.

      Method add(Object) is inherited from AbstractList, but that implementation has an obvious race:
          public boolean add(E e) {
              add(size(), e);

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: