You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/11/03 14:55:07 UTC

[08/10] logging-log4j2 git commit: LOG4J2-1660 use public method ThreadContext::getThreadContextMap instead of the (removed) ThreadContextAccess class.

LOG4J2-1660 use public method ThreadContext::getThreadContextMap instead of the (removed) ThreadContextAccess class.

Also changes to correctly handle the fact that the default ThreadContextMap does not provide a ReadOnlyThreadContextMap view.


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

Branch: refs/heads/master
Commit: d364463b2914b1795e80028df9ac6961bc5b3e35
Parents: b774f1f
Author: rpopma <rp...@apache.org>
Authored: Thu Nov 3 23:53:09 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Nov 3 23:53:09 2016 +0900

----------------------------------------------------------------------
 .../core/async/AbstractAsyncThreadContextTestBase.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d364463b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AbstractAsyncThreadContextTestBase.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AbstractAsyncThreadContextTestBase.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AbstractAsyncThreadContextTestBase.java
index 560f250..f6aa1d4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AbstractAsyncThreadContextTestBase.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AbstractAsyncThreadContextTestBase.java
@@ -24,7 +24,6 @@ import java.io.IOException;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.ThreadContextAccess;
 import org.apache.logging.log4j.ThreadContextTestAccess;
 import org.apache.logging.log4j.core.CoreLoggerContexts;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -32,6 +31,7 @@ import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
 import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.spi.DefaultThreadContextMap;
 import org.apache.logging.log4j.spi.LoggerContext;
+import org.apache.logging.log4j.spi.ReadOnlyThreadContextMap;
 import org.apache.logging.log4j.util.Unbox;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -150,8 +150,7 @@ public abstract class AbstractAsyncThreadContextTestBase {
             } else {
                 ThreadContext.remove("count");
             }
-            final String contextmap = ThreadContextAccess.getThreadContextMap().getClass().getSimpleName();
-            log.info("{} {} {} i={}", contextImpl, contextmap, loggerContextName, Unbox.box(i));
+            log.info("{} {} {} i={}", contextImpl, contextMap(), loggerContextName, Unbox.box(i));
         }
         ThreadContext.pop();
         CoreLoggerContexts.stopLoggerContext(false, files[0]); // stop async thread
@@ -165,6 +164,11 @@ public abstract class AbstractAsyncThreadContextTestBase {
         LogManager.shutdown();
     }
 
+    private static String contextMap() {
+        final ReadOnlyThreadContextMap impl = ThreadContext.getThreadContextMap();
+        return impl == null ? ContextImpl.WEBAPP.implClassSimpleName() : impl.getClass().getSimpleName();
+    }
+
     private void checkResult(final File file, final String loggerContextName) throws IOException {
         final String contextDesc = contextImpl + " " + contextImpl.implClassSimpleName() + " " + loggerContextName;
         try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {