You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ck...@apache.org on 2019/01/14 23:00:15 UTC

[logging-log4j2] branch release-2.x updated (2877ea9 -> 5338ee0)

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

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


    from 2877ea9  Changelog for LOG4J2-2530
     new dae68a6  Remove garbage creation introduced by LOG4J2-2301
     new 63731ca  Adapt the fix for LOG4J2-2533 (github #251) for java 7
     new 5338ee0  Changelog for LOG4J2-2533

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/logging/log4j/core/async/AsyncLoggerConfig.java   | 12 +++++++++---
 src/changes/changes.xml                                      |  3 +++
 2 files changed, 12 insertions(+), 3 deletions(-)


[logging-log4j2] 01/03: Remove garbage creation introduced by LOG4J2-2301

Posted by ck...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dae68a68d6a59468cd15ec3ed0ee42da2457a4b5
Author: mprusakov-rbc <mi...@rbc.com>
AuthorDate: Fri Jan 11 17:50:10 2019 +0000

    Remove garbage creation introduced by LOG4J2-2301
    
    After upgrading to 2.11.1 we have started seeing garbage being generated here:
    
    Stack Trace	TLABs	Total TLAB Size(bytes)	Pressure(%)
    java.lang.ThreadLocal$ThreadLocalMap.set(ThreadLocal, Object) line: 481	10	3,638,864	56.192
       java.lang.ThreadLocal$ThreadLocalMap.access$100(ThreadLocal$ThreadLocalMap, ThreadLocal, Object) line: 298	10	3,638,864	56.192
          java.lang.ThreadLocal.setInitialValue() line: 184	10	3,638,864	56.192
             java.lang.ThreadLocal.get() line: 170	10	3,638,864	56.192
                org.apache.logging.log4j.core.async.AsyncLoggerConfig.log(LogEvent, LoggerConfig$LoggerConfigPredicate) line: 91	10	3,638,864	56.192
    
    The purpose of this patch is to fix this.
---
 .../java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
index 61ca41f..1d2745e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
@@ -72,7 +72,7 @@ import org.apache.logging.log4j.util.Strings;
 @Plugin(name = "asyncLogger", category = Node.CATEGORY, printObject = true)
 public class AsyncLoggerConfig extends LoggerConfig {
 
-    private static final ThreadLocal<Boolean> ASYNC_LOGGER_ENTERED = new ThreadLocal<>();
+    private static final ThreadLocal<Boolean> ASYNC_LOGGER_ENTERED = ThreadLocal.withInitial(() -> Boolean.FALSE);
     private final AsyncLoggerConfigDelegate delegate;
 
     protected AsyncLoggerConfig(final String name,
@@ -90,7 +90,7 @@ public class AsyncLoggerConfig extends LoggerConfig {
     protected void log(final LogEvent event, final LoggerConfigPredicate predicate) {
         // See LOG4J2-2301
         if (predicate == LoggerConfigPredicate.ALL &&
-                ASYNC_LOGGER_ENTERED.get() == null &&
+                ASYNC_LOGGER_ENTERED.get() == Boolean.FALSE &&
                 // Optimization: AsyncLoggerConfig is identical to LoggerConfig
                 // when no appenders are present. Avoid splitting for synchronous
                 // and asynchronous execution paths until encountering an
@@ -109,7 +109,7 @@ public class AsyncLoggerConfig extends LoggerConfig {
                 // from reusable messages.
                 logToAsyncDelegate(event);
             } finally {
-                ASYNC_LOGGER_ENTERED.remove();
+                ASYNC_LOGGER_ENTERED.set(Boolean.FALSE);
             }
         } else {
             super.log(event, predicate);


[logging-log4j2] 02/03: Adapt the fix for LOG4J2-2533 (github #251) for java 7

Posted by ck...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 63731ca8d441af3820b2ed8a5909dd251cbae080
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Mon Jan 14 17:56:17 2019 -0500

    Adapt the fix for LOG4J2-2533 (github #251) for java 7
---
 .../org/apache/logging/log4j/core/async/AsyncLoggerConfig.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
index 1d2745e..33beab3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java
@@ -72,7 +72,13 @@ import org.apache.logging.log4j.util.Strings;
 @Plugin(name = "asyncLogger", category = Node.CATEGORY, printObject = true)
 public class AsyncLoggerConfig extends LoggerConfig {
 
-    private static final ThreadLocal<Boolean> ASYNC_LOGGER_ENTERED = ThreadLocal.withInitial(() -> Boolean.FALSE);
+    private static final ThreadLocal<Boolean> ASYNC_LOGGER_ENTERED = new ThreadLocal<Boolean>() {
+        @Override
+        protected Boolean initialValue() {
+            return Boolean.FALSE;
+        }
+    };
+
     private final AsyncLoggerConfigDelegate delegate;
 
     protected AsyncLoggerConfig(final String name,


[logging-log4j2] 03/03: Changelog for LOG4J2-2533

Posted by ck...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5338ee0a9b16130aa7c41603fb3441693a21c6c9
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Mon Jan 14 17:59:31 2019 -0500

    Changelog for LOG4J2-2533
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5dc8340..660f9b4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -168,6 +168,9 @@
         Introduce new JAVA_UNQUOTED MapMessage format type based on the JAVA formatting, but without
         quoted values.
       </action>
+      <action issue="LOG4J2-2533" dev="ckozak" type="fix" due-to="Michail Prusakov">
+        Fix a regression introduced by LOG4J2-2301 in 2.11.1 allowing allocation to occur in AsyncLoggerConfig.
+      </action>
     </release>
     <release version="2.11.1" date="2018-07-22" description="GA Release 2.11.1">
       <action issue="LOG4J2-2389" dev="rgoers" type="fix" due-to="Liu Wen">