Skip to content

Commit aac2f27

Browse files
committed
Correct exception cause in JTL's TestHelpers (#1381)
1 parent d19028f commit aac2f27

File tree

1 file changed

+9
-13
lines changed
  • log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json

1 file changed

+9
-13
lines changed

log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/TestHelpers.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,18 @@ public static void usingSerializedLogEventAccessor(
7474
final LogEvent logEvent,
7575
final Consumer<MapAccessor> accessorConsumer) {
7676
final String serializedLogEventJson = layout.toSerializable(logEvent);
77-
78-
try {
79-
@SuppressWarnings("unchecked")
80-
final Map<String, Object> deserializedLogEvent =
81-
(Map<String, Object>) readJson(serializedLogEventJson);
82-
83-
final MapAccessor serializedLogEventAccessor = new MapAccessor(deserializedLogEvent);
84-
accessorConsumer.accept(serializedLogEventAccessor);
85-
} catch (Exception e) {
86-
throw new RuntimeException("failed to deserialize log event (" + e
87-
+ "). Serialized Log Event:\n" + serializedLogEventJson);
88-
}
77+
@SuppressWarnings("unchecked")
78+
final Map<String, Object> deserializedLogEvent = (Map<String, Object>) readJson(serializedLogEventJson);
79+
final MapAccessor serializedLogEventAccessor = new MapAccessor(deserializedLogEvent);
80+
accessorConsumer.accept(serializedLogEventAccessor);
8981
}
9082

9183
public static Object readJson(final String json) {
92-
return JsonReader.read(json);
84+
try {
85+
return JsonReader.read(json);
86+
} catch (final Exception error) {
87+
throw new RuntimeException("failed to deserialize the JSON: " + json, error);
88+
}
9389
}
9490

9591
public static Map<String, Object> asMap(final Object... pairs) {

0 commit comments

Comments
 (0)