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

CopyOnWriteArrayList.set should always have volatile write semantics

    XMLWordPrintable

Details

    Backports

      Description

        A user noticed that CopyOnWriteArrayList.set no longer does a volatile write when the new element is already present in its slot.

        https://concurrency.markmail.org/thread/sdx7ehxrjqzrqmiy

        Although such usage is questionable, and one can argue there is no guarantee of happens-before when the element is not in need of an update, and in practice no one will ever notice since the JVM is unlikely to optimize away the synchronized block in the method's implementation, nevertheless we should revert to an unconditional volatile write as seen in jdk8.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: