You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/14 22:14:59 UTC
git commit: Use proper double checked locking as detailed in Item 71
in Effective Java (2d. ed.)
Repository: logging-log4j2
Updated Branches:
refs/heads/master a39c20966 -> fa1ff1109
Use proper double checked locking as detailed in Item 71 in Effective Java (2d. ed.)
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fa1ff110
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fa1ff110
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fa1ff110
Branch: refs/heads/master
Commit: fa1ff1109976a353f51f066aa0a0c2e5d79705e2
Parents: a39c209
Author: Matt Sicker <ma...@apache.org>
Authored: Sun Sep 14 15:14:24 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sun Sep 14 15:14:52 2014 -0500
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/util/CachedClock.java | 10 ++++++----
.../apache/logging/log4j/core/util/CoarseCachedClock.java | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fa1ff110/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CachedClock.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CachedClock.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CachedClock.java
index e9424c1..cdc109e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CachedClock.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CachedClock.java
@@ -52,14 +52,16 @@ public final class CachedClock implements Clock {
public static CachedClock instance() {
// LOG4J2-819: use lazy initialization of threads
- if (instance == null) {
+ CachedClock result = instance;
+ if (result == null) {
synchronized (INSTANCE_LOCK) {
- if (instance == null) {
- instance = new CachedClock();
+ result = instance;
+ if (result == null) {
+ instance = result = new CachedClock();
}
}
}
- return instance;
+ return result;
}
/**
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fa1ff110/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CoarseCachedClock.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CoarseCachedClock.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CoarseCachedClock.java
index 9fa7b15..5f6b3e1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CoarseCachedClock.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CoarseCachedClock.java
@@ -52,14 +52,16 @@ public final class CoarseCachedClock implements Clock {
*/
public static CoarseCachedClock instance() {
// LOG4J2-819: use lazy initialization of threads
- if (instance == null) {
+ CoarseCachedClock result = instance;
+ if (result == null) {
synchronized (INSTANCE_LOCK) {
- if (instance == null) {
- instance = new CoarseCachedClock();
+ result = instance;
+ if (result == null) {
+ instance = result = new CoarseCachedClock();
}
}
}
- return instance;
+ return result;
}
/**