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/10/08 22:41:02 UTC

[2/2] git commit: Don't overwrite external context in Log4jContextFactory.

Don't overwrite external context in Log4jContextFactory.

  - This is consistent with the other two getContext() methods below.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c23fe1c1
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c23fe1c1
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c23fe1c1

Branch: refs/heads/master
Commit: c23fe1c13eff4d25c507bd5a290e92b7da0acd79
Parents: ed18b3d
Author: Matt Sicker <ma...@apache.org>
Authored: Wed Oct 8 15:39:10 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Wed Oct 8 15:39:10 2014 -0500

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/impl/Log4jContextFactory.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c23fe1c1/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
index 67139c7..84f6a9f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
@@ -140,7 +140,9 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
     public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext,
                                     final boolean currentContext) {
         final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext);
-        ctx.setExternalContext(externalContext);
+        if (externalContext != null && ctx.getExternalContext() == null) {
+            ctx.setExternalContext(externalContext);
+        }
         if (ctx.getState() == LifeCycle.State.INITIALIZED) {
             ctx.start();
         }