Jackson version upgrade to fix empty value handling in JsonLayout
@@ -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 ? ":" : " : ";
}
