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
The following commit(s) were added to refs/heads/release-2.x by this push: new 583df1a LOG4J2-2749 Jackson version upgrade to fix empty value handling in JsonLayout (#362) 583df1a is described below commit 583df1af9b46ab537cd2a0e657276d814c26618c Author: Oleksii Khomchenko <akhomche...@gmail.com> AuthorDate: Tue Jun 30 11:51:39 2020 -0700 LOG4J2-2749 Jackson version upgrade to fix empty value handling in JsonLayout (#362) --- .../apache/logging/log4j/core/layout/JsonLayoutTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java index 561b343..b633f88 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java @@ -591,6 +591,19 @@ public class JsonLayoutTest { assertFalse(str.endsWith("\0")); } + @Test // LOG4J2-2749 + public void testEmptyValuesAreIgnored() { + final AbstractJacksonLayout layout = JsonLayout.newBuilder() + .setAdditionalFields(new KeyValuePair[] { + new KeyValuePair("empty", "${ctx:empty:-}") + }) + .setConfiguration(ctx.getConfiguration()) + .build(); + + final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); + assertFalse(str, str.contains("\"empty\"")); + } + private String toPropertySeparator(final boolean compact) { return compact ? ":" : " : "; }