This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 207e728fb2 Use compareAndExchangeRelease with getAcquire
207e728fb2 is described below
commit 207e728fb2cbc65dd67bfa3915eee5f45d178e39
Author: Matt Sicker <[email protected]>
AuthorDate: Thu Nov 17 21:49:25 2022 -0600
Use compareAndExchangeRelease with getAcquire
Using compareAndSet with getAcquire sort of defeats the purpose of the
fence as it uses volatile get which has stronger memory safety than getAcquire.
Signed-off-by: Matt Sicker <[email protected]>
---
log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java
b/log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java
index 10991ca4ad..a75935ea8c 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/LazyUtil.java
@@ -138,7 +138,7 @@ final class LazyUtil {
return unwrapNull(currentValue);
}
final T newValue = supplier.get();
- if (VALUE.compareAndSet(this, (Object) null, wrapNull(newValue))) {
+ if (VALUE.compareAndExchangeRelease(this, null,
wrapNull(newValue)) == null) {
return newValue;
}
final Object value = VALUE.getAcquire(this);