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/03/14 12:27:22 UTC

[logging-log4j2] 09/16: LOG4J2-3393 Remove redundant branching in JsonTemplateLayout.

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

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

commit 970e80e15688a79df46de78e7207699414159b63
Author: Volkan Yazici <vo...@yazi.ci>
AuthorDate: Mon Feb 21 20:43:12 2022 +0100

    LOG4J2-3393 Remove redundant branching in JsonTemplateLayout.
---
 .../logging/log4j/layout/template/json/JsonTemplateLayout.java    | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
index a585bc5..8747c98 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
@@ -287,13 +287,7 @@ public class JsonTemplateLayout implements StringLayout {
             stringBuilder.append(eventDelimiter);
 
             // Write to the destination.
-            if (encoder == null) {
-                final String eventJson = stringBuilder.toString();
-                final byte[] eventJsonBytes = StringEncoder.toBytes(eventJson, charset);
-                destination.writeBytes(eventJsonBytes, 0, eventJsonBytes.length);
-            } else {
-                encoder.encode(stringBuilder, destination);
-            }
+            encoder.encode(stringBuilder, destination);
 
         }