Repository: logging-log4j2
Updated Branches:
  refs/heads/master 666fd7bf0 -> 954dc7d7d


LOG4J2-1271 bugfixes in RingBufferLogEvent


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

Branch: refs/heads/master
Commit: 4bd5161ec7c8155ef05c97be088bd1208c513d6b
Parents: 15d95ec
Author: rpopma <[email protected]>
Authored: Wed Feb 24 21:12:59 2016 +0900
Committer: rpopma <[email protected]>
Committed: Wed Feb 24 21:12:59 2016 +0900

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/async/RingBufferLogEvent.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4bd5161e/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index 6d12afa..010b877 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -96,8 +96,8 @@ public class RingBufferLogEvent implements LogEvent {
             buffer.append(stringBuilder);
 
             // ensure that excessively long char[] arrays are not kept in 
memory forever
-            if (stringBuilder.length() > 512) {
-                stringBuilder.setLength(512);
+            if (stringBuilder.length() > 518) { // resized twice from 128 
(s=s*2+2)
+                stringBuilder.setLength(518);
                 stringBuilder.trimToSize();
             }
         }
@@ -141,6 +141,7 @@ public class RingBufferLogEvent implements LogEvent {
                 // only happens if user logs a custom reused message when 
Constants.ENABLE_THREADLOCALS is false
                 messageText = new StringBuilder(128);
             }
+            messageText.setLength(0);
             ((ReusableMessage) msg).formatTo(messageText);
         } else {
             this.message = msg;

Reply via email to