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 2020/11/18 16:14:28 UTC
[logging-log4j2] 01/01: Align JTL module with the one in
release-2.x.
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 581d5436ea014d7aad628429f30c739dd31c1e74
Author: Volkan Yazıcı <vo...@gmail.com>
AuthorDate: Wed Nov 18 16:30:29 2020 +0100
Align JTL module with the one in release-2.x.
---
log4j-layout-template-json/pom.xml | 10 ++--
log4j-layout-template-json/revapi.json | 39 +++++++--------
.../layout/template/json/JsonTemplateLayout.java | 6 +--
.../json/resolver/ExceptionRootCauseResolver.java | 2 +-
.../template/json/resolver/MessageResolver.java | 58 ++++------------------
.../json/resolver/MessageResolverFactory.java | 2 +-
.../template/json/resolver/SourceResolver.java | 2 +-
.../template/json/resolver/TimestampResolver.java | 2 +-
.../template/json/util/DummyRecyclerFactory.java | 2 +-
.../json/util/QueueingRecyclerFactory.java | 2 +-
.../template/json/util/StringParameterParser.java | 16 ++++++
.../log4j/layout/template/json/EcsLayoutTest.java | 16 ++++++
.../log4j/layout/template/json/GelfLayoutTest.java | 16 ++++++
.../log4j/layout/template/json/JsonLayoutTest.java | 16 ++++++
.../JsonTemplateLayoutNullEventDelimiterTest.java | 16 ++++++
.../template/json/JsonTemplateLayoutTest.java | 2 +-
.../template/json/LayoutComparisonHelpers.java | 16 ++++++
.../log4j/layout/template/json/LogstashIT.java | 16 ++++++
.../layout/template/json/util/JsonWriterTest.java | 16 +-----
.../json/util/StringParameterParserTest.java | 16 ++++++
.../json/util/TruncatingBufferedWriterTest.java | 16 ++++++
21 files changed, 187 insertions(+), 100 deletions(-)
diff --git a/log4j-layout-template-json/pom.xml b/log4j-layout-template-json/pom.xml
index 5d6d0ae..11decbd 100644
--- a/log4j-layout-template-json/pom.xml
+++ b/log4j-layout-template-json/pom.xml
@@ -36,8 +36,8 @@
<properties>
<log4jParentDir>${basedir}/..</log4jParentDir>
<docLabel>Log4j Layout for JSON Template Documentation</docLabel>
- <projectDir>/log4j-layout-json-template</projectDir>
- <module.name>org.apache.logging.log4j.layout.json.template</module.name>
+ <projectDir>/log4j-layout-template-json</projectDir>
+ <module.name>org.apache.logging.log4j.layout.template.json</module.name>
<maven.doap.skip>true</maven.doap.skip>
</properties>
@@ -124,7 +124,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Fragment-Host>org.apache.logging.log4j.layout.json.template</Fragment-Host>
+ <Fragment-Host>org.apache.logging.log4j.layout.template.json</Fragment-Host>
<Export-Package>*</Export-Package>
</instructions>
</configuration>
@@ -352,7 +352,7 @@
</ports>
<network>
<mode>custom</mode>
- <name>log4j-layout-json-template-network</name>
+ <name>log4j-layout-template-json-network</name>
<alias>elasticsearch</alias>
</network>
<log>
@@ -374,7 +374,7 @@
</dependsOn>
<network>
<mode>custom</mode>
- <name>log4j-layout-json-template-network</name>
+ <name>log4j-layout-template-json-network</name>
<alias>logstash</alias>
</network>
<ports>
diff --git a/log4j-layout-template-json/revapi.json b/log4j-layout-template-json/revapi.json
index 65fa2e3..20bd8ed 100644
--- a/log4j-layout-template-json/revapi.json
+++ b/log4j-layout-template-json/revapi.json
@@ -1,42 +1,37 @@
[
{
+ "extension": "revapi.java",
+ "configuration": {
+ "filter": {
+ "classes": {
+ "exclude": [
+ "org\\.apache\\.logging\\.log4j\\.layout\\.template\\.json\\.resolver\\.TemplateResolverConfig",
+ "org\\.apache\\.logging\\.log4j\\.layout\\.template\\.json\\.resolver\\.TemplateResolverContext",
+ "org\\.apache\\.logging\\.log4j\\.layout\\.template\\.json\\.resolver\\.TemplateResolverFactory"
+ ]
+ }
+ }
+ }
+ },
+ {
"extension": "revapi.ignore",
"configuration": [
{
"code": "java.method.returnTypeChanged",
"old": "method org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder::getEventTemplateAdditionalFields()",
"new": "method org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField[] org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder::getEventTemplateAdditionalFields()",
- "justification": "Refactored for simplicity since it was already broken on release-2.x due to missing @PluginBuilderAttribute annotations",
- "oldType": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields",
- "newType": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField[]",
- "package": "org.apache.logging.log4j.layout.template.json",
- "classQualifiedName": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder",
- "classSimpleName": "Builder",
- "methodName": "getEventTemplateAdditionalFields",
- "elementKind": "method"
+ "justification": "LOG4J2-2961 Refactored for simplicity since it was already broken due to missing @PluginBuilderAttribute annotations"
},
{
"code": "java.method.parameterTypeChanged",
"old": "parameter org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder::setEventTemplateAdditionalFields(===org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields===)",
"new": "parameter org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder::setEventTemplateAdditionalFields(===org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField[]===)",
- "justification": "Refactored for simplicity since it was already broken on release-2.x due to missing @PluginBuilderAttribute annotations",
- "oldType": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields",
- "newType": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField[]",
- "package": "org.apache.logging.log4j.layout.template.json",
- "classQualifiedName": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.Builder",
- "classSimpleName": "Builder",
- "methodName": "setEventTemplateAdditionalFields",
- "parameterIndex": "0",
- "elementKind": "parameter"
+ "justification": "LOG4J2-2961 Refactored for simplicity since it was already broken due to missing @PluginBuilderAttribute annotations"
},
{
"code": "java.class.removed",
"old": "class org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields",
- "justification": "Refactored for simplicity since it was already broken on release-2.x due to missing @PluginBuilderAttribute annotations",
- "package": "org.apache.logging.log4j.layout.template.json",
- "classQualifiedName": "org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalFields",
- "classSimpleName": "EventTemplateAdditionalFields",
- "elementKind": "class"
+ "justification": "LOG4J2-2961 Refactored for simplicity since it was already broken due to missing @PluginBuilderAttribute annotations"
}
]
}
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 9b65f6d..c8c4c22 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
@@ -238,11 +238,7 @@ public class JsonTemplateLayout implements StringLayout {
// Render the JSON.
eventResolver.resolve(event, jsonWriter);
- if (eventDelimiter != null && eventDelimiter.equalsIgnoreCase("null")) {
- stringBuilder.append('\0');
- } else {
- stringBuilder.append(eventDelimiter);
- }
+ stringBuilder.append(eventDelimiter);
// Write to the destination.
if (encoder == null) {
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/ExceptionRootCauseResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/ExceptionRootCauseResolver.java
index ce3a08e..5218284 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/ExceptionRootCauseResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/ExceptionRootCauseResolver.java
@@ -18,8 +18,8 @@ package org.apache.logging.log4j.layout.template.json.resolver;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.util.Throwables;
-import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
import org.apache.logging.log4j.layout.template.json.JsonTemplateLayout;
+import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
/**
* Exception root cause resolver.
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolver.java
index 997da2f..f42dbab 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolver.java
@@ -17,8 +17,6 @@
package org.apache.logging.log4j.layout.template.json.resolver;
import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.layout.PatternLayout;
import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
import org.apache.logging.log4j.message.MapMessage;
import org.apache.logging.log4j.message.Message;
@@ -84,37 +82,21 @@ import org.apache.logging.log4j.util.StringBuilderFormattable;
final class MessageResolver implements EventResolver {
private static final String[] FORMATS = { "JSON" };
- /**
- * Default length for new StringBuilder instances: {@value} .
- */
- protected static final int DEFAULT_STRING_BUILDER_SIZE = 1024;
private final EventResolver internalResolver;
- private PatternLayout patternLayout;
-
- MessageResolver(final Configuration configuration, final TemplateResolverConfig config) {
- this.internalResolver = createInternalResolver(configuration, config);
+ MessageResolver(final TemplateResolverConfig config) {
+ this.internalResolver = createInternalResolver(config);
}
static String getName() {
return "message";
}
- private EventResolver createInternalResolver(final Configuration configuration,
+ private static EventResolver createInternalResolver(
final TemplateResolverConfig config) {
final boolean stringified = config.getBoolean("stringified", false);
final String fallbackKey = config.getString("fallbackKey");
- final String pattern = config.getString("pattern");
- final boolean includeStacktrace = config.getBoolean("includeStacktrace", true);
- if (pattern != null) {
- patternLayout = PatternLayout.newBuilder().setPattern(pattern)
- .setAlwaysWriteExceptions(includeStacktrace)
- .setConfiguration(configuration)
- .build();
- } else {
- patternLayout = null;
- }
if (stringified && fallbackKey != null) {
throw new IllegalArgumentException(
"fallbackKey is not allowed when stringified is enable: " + config);
@@ -131,26 +113,20 @@ final class MessageResolver implements EventResolver {
internalResolver.resolve(logEvent, jsonWriter);
}
- private EventResolver createStringResolver(final String fallbackKey) {
+ private static EventResolver createStringResolver(final String fallbackKey) {
return (final LogEvent logEvent, final JsonWriter jsonWriter) ->
resolveString(fallbackKey, logEvent, jsonWriter);
}
- private void resolveString(
+ private static void resolveString(
final String fallbackKey,
final LogEvent logEvent,
final JsonWriter jsonWriter) {
- if (patternLayout != null) {
- final StringBuilder messageBuffer = getMessageStringBuilder();
- patternLayout.serialize(logEvent, messageBuffer);
- jsonWriter.writeString(messageBuffer.toString());
- } else {
- final Message message = logEvent.getMessage();
- resolveString(fallbackKey, message, jsonWriter);
- }
+ final Message message = logEvent.getMessage();
+ resolveString(fallbackKey, message, jsonWriter);
}
- private void resolveString(
+ private static void resolveString(
final String fallbackKey,
final Message message,
final JsonWriter jsonWriter) {
@@ -171,7 +147,7 @@ final class MessageResolver implements EventResolver {
}
}
- private EventResolver createObjectResolver(final String fallbackKey) {
+ private static EventResolver createObjectResolver(final String fallbackKey) {
return (final LogEvent logEvent, final JsonWriter jsonWriter) -> {
// Skip custom serializers for SimpleMessage.
@@ -197,7 +173,7 @@ final class MessageResolver implements EventResolver {
};
}
- private boolean writeMultiformatMessage(
+ private static boolean writeMultiformatMessage(
final JsonWriter jsonWriter,
final Message message) {
@@ -227,7 +203,7 @@ final class MessageResolver implements EventResolver {
}
- private boolean writeObjectMessage(
+ private static boolean writeObjectMessage(
final JsonWriter jsonWriter,
final Message message) {
@@ -244,16 +220,4 @@ final class MessageResolver implements EventResolver {
}
- private static final ThreadLocal<StringBuilder> messageStringBuilder = new ThreadLocal<>();
-
- private static StringBuilder getMessageStringBuilder() {
- StringBuilder result = messageStringBuilder.get();
- if (result == null) {
- result = new StringBuilder(DEFAULT_STRING_BUILDER_SIZE);
- messageStringBuilder.set(result);
- }
- result.setLength(0);
- return result;
- }
-
}
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverFactory.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverFactory.java
index c4f48b4..5e2a3db 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverFactory.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverFactory.java
@@ -35,7 +35,7 @@ final class MessageResolverFactory implements EventResolverFactory<MessageResolv
public MessageResolver create(
final EventResolverContext context,
final TemplateResolverConfig config) {
- return new MessageResolver(context.getConfiguration(), config);
+ return new MessageResolver(config);
}
}
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/SourceResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/SourceResolver.java
index a83e666..b4e63e3 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/SourceResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/SourceResolver.java
@@ -17,8 +17,8 @@
package org.apache.logging.log4j.layout.template.json.resolver;
import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
import org.apache.logging.log4j.layout.template.json.JsonTemplateLayout;
+import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
/**
* Resolver for the {@link StackTraceElement} returned by {@link LogEvent#getSource()}.
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TimestampResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TimestampResolver.java
index dfaafde..7049e23 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TimestampResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/TimestampResolver.java
@@ -18,7 +18,7 @@ package org.apache.logging.log4j.layout.template.json.resolver;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.time.Instant;
-import org.apache.logging.log4j.core.time.internal.format.FastDateFormat;
+import org.apache.logging.log4j.core.util.datetime.FastDateFormat;
import org.apache.logging.log4j.layout.template.json.JsonTemplateLayoutDefaults;
import org.apache.logging.log4j.layout.template.json.util.JsonWriter;
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/DummyRecyclerFactory.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/DummyRecyclerFactory.java
index d2b6f77..2a96d98 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/DummyRecyclerFactory.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/DummyRecyclerFactory.java
@@ -33,7 +33,7 @@ public class DummyRecyclerFactory implements RecyclerFactory {
public <V> Recycler<V> create(
final Supplier<V> supplier,
final Consumer<V> cleaner) {
- return new DummyRecycler<V>(supplier);
+ return new DummyRecycler<>(supplier);
}
}
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/QueueingRecyclerFactory.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/QueueingRecyclerFactory.java
index 7ce41d3..85b04ab 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/QueueingRecyclerFactory.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/QueueingRecyclerFactory.java
@@ -34,7 +34,7 @@ public class QueueingRecyclerFactory implements RecyclerFactory {
final Consumer<V> cleaner) {
@SuppressWarnings("unchecked")
final Queue<V> queue = (Queue<V>) queueSupplier.get();
- return new QueueingRecycler<V>(supplier, cleaner, queue);
+ return new QueueingRecycler<>(supplier, cleaner, queue);
}
}
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
index 9524a19..2952d06 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json.util;
import org.apache.logging.log4j.util.Strings;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/EcsLayoutTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/EcsLayoutTest.java
index 6d3e89a..4be0c7f 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/EcsLayoutTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/EcsLayoutTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import co.elastic.logging.log4j2.EcsLayout;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/GelfLayoutTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/GelfLayoutTest.java
index b13f939..9d32cf3 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/GelfLayoutTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/GelfLayoutTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import org.apache.logging.log4j.core.LogEvent;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonLayoutTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonLayoutTest.java
index aba08ad..f567310 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonLayoutTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonLayoutTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import org.apache.logging.log4j.core.LogEvent;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
index 73d365c..4af1ca1 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import org.apache.logging.log4j.Level;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutTest.java
index ec881c3..fa62793 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutTest.java
@@ -1135,7 +1135,7 @@ public class JsonTemplateLayoutTest {
}
- private static final class NonAsciiUtf8MethodNameContainingException extends RuntimeException {;
+ private static final class NonAsciiUtf8MethodNameContainingException extends RuntimeException {
public static final long serialVersionUID = 0;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LayoutComparisonHelpers.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LayoutComparisonHelpers.java
index c1a9b37..e0be875 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LayoutComparisonHelpers.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LayoutComparisonHelpers.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import org.apache.logging.log4j.core.Layout;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LogstashIT.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LogstashIT.java
index 2e59743..62c2222 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LogstashIT.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/LogstashIT.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json;
import co.elastic.logging.log4j2.EcsLayout;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/JsonWriterTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/JsonWriterTest.java
index cde4ccf..def4d42 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/JsonWriterTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/JsonWriterTest.java
@@ -375,14 +375,8 @@ public class JsonWriterTest {
@Test
public void test_writeString_formattable() {
final String expectedJson = "\"foo\\tbar\\tbuzz\"";
- @SuppressWarnings("Convert2Lambda")
final String actualJson = WRITER.use(() ->
- WRITER.writeString(new StringBuilderFormattable() {
- @Override
- public void formatTo(StringBuilder stringBuilder) {
- stringBuilder.append("foo\tbar\tbuzz");
- }
- }));
+ WRITER.writeString(stringBuilder -> stringBuilder.append("foo\tbar\tbuzz")));
Assertions.assertThat(actualJson).isEqualTo(expectedJson);
}
@@ -394,14 +388,8 @@ public class JsonWriterTest {
excessiveString.substring(0, maxStringLength) +
WRITER.getTruncatedStringSuffix() +
'"';
- @SuppressWarnings("Convert2Lambda")
final String actualJson = WRITER.use(() ->
- WRITER.writeString(new StringBuilderFormattable() {
- @Override
- public void formatTo(StringBuilder stringBuilder) {
- stringBuilder.append(excessiveString);
- }
- }));
+ WRITER.writeString(stringBuilder -> stringBuilder.append(excessiveString)));
Assertions.assertThat(actualJson).isEqualTo(expectedJson);
}
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParserTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParserTest.java
index 651f3b1..601c578 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParserTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParserTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json.util;
import org.apache.logging.log4j.layout.template.json.util.StringParameterParser.DoubleQuotedStringValue;
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/TruncatingBufferedWriterTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/TruncatingBufferedWriterTest.java
index 4b3d3e0..6e46197 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/TruncatingBufferedWriterTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/TruncatingBufferedWriterTest.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
package org.apache.logging.log4j.layout.template.json.util;
import org.assertj.core.api.Assertions;