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 06:01:17 UTC

[logging-log4j2] branch release-2.x updated: Fix issue found by spotbugs

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

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/release-2.x by this push:
     new b5eeb00  Fix issue found by spotbugs
b5eeb00 is described below

commit b5eeb005db631c22768430fdd510ad3c6c103c49
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Tue Apr 6 23:01:05 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 cc07b7d..a3dd948 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;