From cdaa7556225869408656a1d5a32b67de314c2dc4 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Fri, 3 Apr 2020 16:36:23 +0200 Subject: [PATCH] Remove call stack from original exceptions in log Change-Id: Id6201dc6d6d451d9f3ce2b8c5521f5c27d6c47ac Signed-off-by: elinuxhenrik --- .../main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java | 2 +- .../main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java | 5 +++-- .../java/org/oransc/policyagent/tasks/RicSynchronizationTask.java | 5 +++-- .../main/java/org/oransc/policyagent/tasks/ServiceSupervision.java | 3 ++- .../java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java | 5 +---- .../org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java | 2 +- .../java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java | 5 +++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java index fc6e439a..3c44f085 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java @@ -58,7 +58,7 @@ public class DmaapMessageHandler { public void handleDmaapMsg(String msg) { this.createTask(msg) // .subscribe(message -> logger.debug("handleDmaapMsg: {}", message), // - throwable -> logger.warn("handleDmaapMsg failure ", throwable), // + throwable -> logger.warn("handleDmaapMsg failure {}", throwable.getMessage()), // () -> logger.debug("handleDmaapMsg complete")); } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java index a6bbeeae..35da96d2 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java @@ -109,8 +109,9 @@ public class RefreshConfigTask { logger.debug("Starting refreshConfigTask"); stop(); refreshTask = createRefreshTask() // - .subscribe(notUsed -> logger.debug("Refreshed configuration data"), - throwable -> logger.error("Configuration refresh terminated due to exception", throwable), + .subscribe( + notUsed -> logger.debug("Refreshed configuration data"), throwable -> logger + .error("Configuration refresh terminated due to exception {}", throwable.getMessage()), () -> logger.error("Configuration refresh terminated")); } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java index 00ca0edc..e985fd39 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java @@ -137,8 +137,9 @@ public class RicSynchronizationTask { createNotificationClient(url) // .put("", body) // .subscribe( // - notUsed -> logger.debug("Service {} notified", service.getName()), throwable -> logger - .warn("Service notification failed for service: {}", service.getName(), throwable), + notUsed -> logger.debug("Service {} notified", service.getName()), + throwable -> logger.warn("Service notification failed for service: {}. Cause: {}", + service.getName(), throwable.getMessage()), () -> logger.debug("All services notified")); } } diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java index 50e990cf..751c0ac0 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java @@ -116,7 +116,8 @@ public class ServiceSupervision { } private Mono handleDeleteFromRicFailure(Policy policy, Throwable e) { - logger.warn("Could not delete policy: {} from ric: {}", policy.id(), policy.ric().name(), e); + logger.warn("Could not delete policy: {} from ric: {}. Cause: {}", policy.id(), policy.ric().name(), + e.getMessage()); return Mono.empty(); } } diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java index 1c4b21d1..e8f0ec94 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java @@ -40,7 +40,6 @@ import com.google.gson.JsonIOException; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -53,7 +52,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Properties; import java.util.Vector; - import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -79,7 +77,6 @@ import org.oransc.policyagent.repository.Ric; import org.oransc.policyagent.repository.Rics; import org.oransc.policyagent.repository.Services; import org.oransc.policyagent.utils.LoggingUtils; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -151,7 +148,7 @@ public class RefreshConfigTaskTest { refreshTaskUnderTest.start(); ILoggingEvent event = logAppender.list.get(0); - assertThat(event.getThrowableProxy().getMessage()).isEqualTo("Error"); + assertThat(event.getLevel()).isEqualTo(ERROR); assertThat(event.toString().contains("Configuration refresh terminated due to exception")).isTrue(); } diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java index 788253c8..1fae425a 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java @@ -299,7 +299,7 @@ public class RicSynchronizationTaskTest { synchronizerUnderTest.run(RIC_1); ILoggingEvent loggingEvent = logAppender.list.get(0); - assertThat(loggingEvent.getThrowableProxy().getMessage()).isEqualTo(originalErrorMessage); + assertThat(loggingEvent.getLevel()).isEqualTo(WARN); verifyCorrectLogMessage(0, logAppender, "Service notification failed for service: " + SERVICE_1_NAME); } diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java index 8961615a..f26083a5 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java @@ -132,8 +132,9 @@ public class ServiceSupervisionTest { assertThat(services.size()).isEqualTo(0); ILoggingEvent loggingEvent = logAppender.list.get(0); - assertThat(loggingEvent.getThrowableProxy().getMessage()).isEqualTo(originalErrorMessage); - String expectedLogMessage = "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME; + assertThat(loggingEvent.getLevel()).isEqualTo(WARN); + String expectedLogMessage = + "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage; assertThat(loggingEvent.toString().contains(expectedLogMessage)).isTrue(); } -- 2.16.6