Skip to content

Commit 99f9769

Browse files
Handle scenario when throwable proxy is not an instance of ThrowableProxy
1 parent 19c32d2 commit 99f9769

File tree

1 file changed

+4
-4
lines changed
  • logback-ecs-encoder/src/main/java/co/elastic/logging/logback

1 file changed

+4
-4
lines changed

logback-ecs-encoder/src/main/java/co/elastic/logging/logback/EcsEncoder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ public byte[] encode(ILoggingEvent event) {
118118
}
119119
}
120120
IThrowableProxy throwableProxy = event.getThrowableProxy();
121-
if (throwableProxy instanceof ThrowableProxy) {
121+
if (throwableProxy != null) {
122122
if (throwableConverter != null) {
123123
EcsJsonSerializer.serializeException(builder, throwableProxy.getClassName(), throwableProxy.getMessage(), throwableConverter.convert(event), stackTraceAsArray);
124-
} else {
124+
} else if (throwableProxy instanceof ThrowableProxy) {
125125
EcsJsonSerializer.serializeException(builder, ((ThrowableProxy) throwableProxy).getThrowable(), stackTraceAsArray);
126+
} else {
127+
EcsJsonSerializer.serializeException(builder, throwableProxy.getClassName(), throwableProxy.getMessage(), throwableProxyConverter.convert(event), stackTraceAsArray);
126128
}
127-
} else if (throwableProxy != null) {
128-
EcsJsonSerializer.serializeException(builder, throwableProxy.getClassName(), throwableProxy.getMessage(), throwableProxyConverter.convert(event), stackTraceAsArray);
129129
}
130130
EcsJsonSerializer.serializeObjectEnd(builder);
131131
// all these allocations kinda hurt

0 commit comments

Comments
 (0)