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 2020/02/17 23:46:11 UTC

[logging-log4j2] branch release-2.x updated: LOG4J2-2746 - ClassLoaderContextSelector was not locating the LoggerContext during shutdown.

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 8b526a0  LOG4J2-2746 - ClassLoaderContextSelector was not locating the LoggerContext during shutdown.
8b526a0 is described below

commit 8b526a01aecc3d07fd42b330aa532ca16f25fcb7
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Mon Feb 17 16:45:57 2020 -0700

    LOG4J2-2746 - ClassLoaderContextSelector was not locating the LoggerContext during shutdown.
---
 .../logging/log4j/core/selector/ClassLoaderContextSelector.java       | 4 +++-
 src/changes/changes.xml                                               | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
index ada4ae7..71217c0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
@@ -67,7 +67,9 @@ public class ClassLoaderContextSelector implements ContextSelector, LoggerContex
             if (clazz != null) {
                 ctx = findContext(clazz.getClassLoader());
             }
-            ctx = ContextAnchor.THREAD_CONTEXT.get();
+            if (ctx == null) {
+                ctx = ContextAnchor.THREAD_CONTEXT.get();
+            }
         }
         if (ctx != null) {
             ctx.stop(DEFAULT_STOP_TIMEOUT, TimeUnit.MILLISECONDS);
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 664b41c..61fb32b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.13.1" date="2019-MM-DD" description="GA Release 2.13.1">
+      <action issue="LOG4J2-2746" dev="rgoers" type="fix">
+        ClassLoaderContextSelector was not locating the LoggerContext during shutdown.
+      </action>
       <action issue="LOG4J2-2652" dev="rgoers" type="fix">
         JSON output wrong when using additonal fields.
       </action>