8221120: CopyOnWriteArrayList.set should always have volatile write semantics
Reviewed-by: martin
--- 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;
}
}