This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new aac2f27ccd Correct exception cause in JTL's `TestHelpers` (#1381)
aac2f27ccd is described below
commit aac2f27ccd55d3aaf50e19ac3ce91213a2089733
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Tue Mar 21 22:43:37 2023 +0100
Correct exception cause in JTL's `TestHelpers` (#1381)
---
.../log4j/layout/template/json/TestHelpers.java | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git
a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/TestHelpers.java
b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/TestHelpers.java
index e7dc52463b..d9a7908d8e 100644
---
a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/TestHelpers.java
+++
b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/TestHelpers.java
@@ -74,22 +74,18 @@ public final class TestHelpers {
final LogEvent logEvent,
final Consumer<MapAccessor> accessorConsumer) {
final String serializedLogEventJson = layout.toSerializable(logEvent);
-
- try {
- @SuppressWarnings("unchecked")
- final Map<String, Object> deserializedLogEvent =
- (Map<String, Object>) readJson(serializedLogEventJson);
-
- final MapAccessor serializedLogEventAccessor = new
MapAccessor(deserializedLogEvent);
- accessorConsumer.accept(serializedLogEventAccessor);
- } catch (Exception e) {
- throw new RuntimeException("failed to deserialize log event (" + e
- + "). Serialized Log Event:\n" + serializedLogEventJson);
- }
+ @SuppressWarnings("unchecked")
+ final Map<String, Object> deserializedLogEvent = (Map<String, Object>)
readJson(serializedLogEventJson);
+ final MapAccessor serializedLogEventAccessor = new
MapAccessor(deserializedLogEvent);
+ accessorConsumer.accept(serializedLogEventAccessor);
}
public static Object readJson(final String json) {
- return JsonReader.read(json);
+ try {
+ return JsonReader.read(json);
+ } catch (final Exception error) {
+ throw new RuntimeException("failed to deserialize the JSON: " +
json, error);
+ }
}
public static Map<String, Object> asMap(final Object... pairs) {