8221120: CopyOnWriteArrayList.set should always have volatile write semantics
authordl
Thu, 02 May 2019 06:33:28 -0700
changeset 54683 3ffdc15cd044
parent 54682 79d13fd7db9c
child 54684 c277ec29ee12
8221120: CopyOnWriteArrayList.set should always have volatile write semantics Reviewed-by: martin
src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
--- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu May 02 06:33:28 2019 -0700
+++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu May 02 06:33:28 2019 -0700
@@ -413,8 +413,9 @@
             if (oldValue != element) {
                 es = es.clone();
                 es[index] = element;
-                setArray(es);
             }
+            // Ensure volatile write semantics even when oldvalue == element
+            setArray(es);
             return oldValue;
         }
     }