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/15 01:27:03 UTC

[14/21] git commit: Use proper double checked locking as detailed in Item 71 in Effective Java (2d. ed.)

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/0dcb0f0c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0dcb0f0c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0dcb0f0c

Branch: refs/heads/master
Commit: 0dcb0f0cd808d044e34e0dfe9d029c36002045ac
Parents: 001bd2f
Author: Matt Sicker <ma...@apache.org>
Authored: Sun Sep 14 15:17:06 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Sun Sep 14 15:17:06 2014 -0500

----------------------------------------------------------------------
 .../log4j/core/config/plugins/util/PluginRegistry.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0dcb0f0c/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java
index 8c362fd..88d999d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java
@@ -79,14 +79,16 @@ public class PluginRegistry {
      * @since 2.1
      */
     public static PluginRegistry getInstance() {
-        if (INSTANCE == null) {
+        PluginRegistry result = INSTANCE;
+        if (result == null) {
             synchronized (INSTANCE_LOCK) {
-                if (INSTANCE == null) {
-                    INSTANCE = new PluginRegistry();
+                result = INSTANCE;
+                if (result == null) {
+                    INSTANCE = result = new PluginRegistry();
                 }
             }
         }
-        return INSTANCE;
+        return result;
     }
 
     /**