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

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


The following commit(s) were added to refs/heads/2.x by this push:
     new cf4b39e455 Port `JndiContextSelector` bit from `main`
cf4b39e455 is described below

commit cf4b39e4557b52ae6f6c14629e3851385652859f
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Wed Jan 10 15:31:04 2024 +0100

    Port `JndiContextSelector` bit from `main`
---
 .../logging/log4j/core/selector/JndiContextSelector.java       | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/JndiContextSelector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/JndiContextSelector.java
index 57a261ad5c..33884a7d95 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/JndiContextSelector.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/JndiContextSelector.java
@@ -140,18 +140,12 @@ public class JndiContextSelector implements 
NamedContextSelector {
             return lc;
         }
 
-        String loggingContextName = null;
-
-        try (final JndiManager jndiManager = JndiManager.getDefaultManager()) {
-            loggingContextName = 
jndiManager.lookup(Constants.JNDI_CONTEXT_NAME);
-        } catch (final NamingException ne) {
-            LOGGER.error("Unable to lookup {}", Constants.JNDI_CONTEXT_NAME, 
ne);
-        }
+        String loggingContextName = getContextName();
 
         return loggingContextName == null ? CONTEXT : 
locateContext(loggingContextName, null, configLocation);
     }
 
-    private String getContextName() {
+    private static String getContextName() {
         String loggingContextName = null;
 
         try (final JndiManager jndiManager = JndiManager.getDefaultManager()) {

Reply via email to