From 80b7ddc77a878d0974a3175f9cf4d2f0cff779cd Mon Sep 17 00:00:00 2001 From: stigus Date: Thu, 2 May 2024 09:49:57 +0200 Subject: [PATCH] Fiks etter kommentar --- .../reactivecore/logging/TestnavLogbackEncoder.java | 12 ++++++------ .../servletcore/logging/TestnavLogbackEncoder.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java b/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java index 2900cde1ad7..544251c47d6 100644 --- a/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java +++ b/libs/reactive-core/src/main/java/no/nav/testnav/libs/reactivecore/logging/TestnavLogbackEncoder.java @@ -12,7 +12,7 @@ import java.io.StringWriter; import java.util.regex.Pattern; -import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; @Slf4j public class TestnavLogbackEncoder extends LogstashEncoder { @@ -36,15 +36,15 @@ public byte[] encode(ILoggingEvent event) { generator.writeStringField("thread_name", event.getThreadName()); generator.writeStringField("level", event.getLevel().toString()); - if (!isNull(event.getThrowableProxy())) { + if (nonNull(event.getThrowableProxy())) { var exception = (ThrowableProxy) event.getThrowableProxy(); - if (!isNull(exception.getThrowable())) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); + if (nonNull(exception.getThrowable())) { + var sw = new StringWriter(); + var pw = new PrintWriter(sw); for (StackTraceElement element : exception.getThrowable().getStackTrace()) { pw.println("\tat " + element); } - String stackTrace = sw.toString().substring(0, 480); //Limit the stack trace to 480 characters + var stackTrace = sw.toString().substring(0, 480); //Limit the stack trace to 480 characters generator.writeStringField("stack_trace", stackTrace); } } diff --git a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java index 5577d41e9a3..440949ff602 100644 --- a/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java +++ b/libs/servlet-core/src/main/java/no/nav/testnav/libs/servletcore/logging/TestnavLogbackEncoder.java @@ -12,7 +12,7 @@ import java.io.StringWriter; import java.util.regex.Pattern; -import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; @Slf4j public class TestnavLogbackEncoder extends LogstashEncoder { @@ -36,15 +36,15 @@ public byte[] encode(ILoggingEvent event) { generator.writeStringField("thread_name", event.getThreadName()); generator.writeStringField("level", event.getLevel().toString()); - if (!isNull(event.getThrowableProxy())) { + if (nonNull(event.getThrowableProxy())) { var exception = (ThrowableProxy) event.getThrowableProxy(); - if (!isNull(exception.getThrowable())) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); + if (nonNull(exception.getThrowable())) { + var sw = new StringWriter(); + var pw = new PrintWriter(sw); for (StackTraceElement element : exception.getThrowable().getStackTrace()) { pw.println("\tat " + element); } - String stackTrace = sw.toString().substring(0, 480); //Limit the stack trace to 480 characters + var stackTrace = sw.toString().substring(0, 480); //Limit the stack trace to 480 characters generator.writeStringField("stack_trace", stackTrace); } }