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

CopyOnWriteArrayList subList needs more synchronization

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • None
    • core-libs
    • None

      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);

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

              Created:
              Updated:
              Resolved: