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

CopyOnWriteArrayList.set should always have volatile write semantics

    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

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: