You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2021/04/07 05:58:46 UTC

[logging-log4j2] branch master updated: Fix issue found by spotbugs

This is an automated email from the ASF dual-hosted git repository.

rgoers 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 a208714  Fix issue found by spotbugs
a208714 is described below

commit a2087146ab449b8833788215e40d87b202f64a17
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Tue Apr 6 22:58:36 2021 -0700

    Fix issue found by spotbugs
---
 .../org/apache/logging/log4j/kubernetes/KubernetesLookup.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/KubernetesLookup.java b/log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/KubernetesLookup.java
index 2a16a9e..016c67c 100644
--- a/log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/KubernetesLookup.java
+++ b/log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/KubernetesLookup.java
@@ -78,9 +78,9 @@ public class KubernetesLookup extends AbstractLookup {
     private boolean initialize() {
         if (kubernetesInfo == null || (isSpringIncluded && !kubernetesInfo.isSpringActive)) {
             initLock.lock();
-            boolean isSpringActive = isSpringActive();
-            if (kubernetesInfo == null || (!kubernetesInfo.isSpringActive && isSpringActive)) {
-                try {
+            try {
+                boolean isSpringActive = isSpringActive();
+                if (kubernetesInfo == null || (!kubernetesInfo.isSpringActive && isSpringActive)) {
                     KubernetesInfo info = new KubernetesInfo();
                     KubernetesClient client = null;
                     info.isSpringActive = isSpringActive;
@@ -152,9 +152,9 @@ public class KubernetesLookup extends AbstractLookup {
 
                         kubernetesInfo = info;
                     }
-                } finally {
-                    initLock.unlock();
                 }
+            } finally {
+                initLock.unlock();
             }
         }
         return kubernetesInfo != null;