You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2022/02/18 10:37:33 UTC

[logging-log4j2] 01/02: LOG4J2-3393 Fix StringBuilder sizing code typo in JsonWriter#trimStringBuilder().

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

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

commit 3913f59148eae79d9475f5a798cb8c837d10a35a
Author: Volkan Yazici <vo...@yazi.ci>
AuthorDate: Wed Feb 16 17:07:11 2022 +0100

    LOG4J2-3393 Fix StringBuilder sizing code typo in JsonWriter#trimStringBuilder().
---
 .../org/apache/logging/log4j/layout/template/json/util/JsonWriter.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java
index 24c8f57..2d5df72 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java
@@ -854,7 +854,7 @@ public final class JsonWriter implements AutoCloseable, Cloneable {
 
     private void trimStringBuilder(final StringBuilder stringBuilder, final int length) {
         final int trimLength = Math.max(maxStringLength, length);
-        if (stringBuilder.length() > trimLength) {
+        if (stringBuilder.capacity() > trimLength) {
             stringBuilder.setLength(trimLength);
             stringBuilder.trimToSize();
         }