Remove call stack from original exceptions in log 35/3135/2
authorelinuxhenrik <henrik.b.andersson@est.tech>
Fri, 3 Apr 2020 14:36:23 +0000 (16:36 +0200)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 7 Apr 2020 06:17:59 +0000 (08:17 +0200)
Change-Id: Id6201dc6d6d451d9f3ce2b8c5521f5c27d6c47ac
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/RefreshConfigTask.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/RicSynchronizationTask.java
policy-agent/src/main/java/org/oransc/policyagent/tasks/ServiceSupervision.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/RefreshConfigTaskTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/RicSynchronizationTaskTest.java
policy-agent/src/test/java/org/oransc/policyagent/tasks/ServiceSupervisionTest.java

index fc6e439..3c44f08 100644 (file)
@@ -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"));
     }
 
index a6bbeea..35da96d 100644 (file)
@@ -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"));
     }
 
index 00ca0ed..e985fd3 100644 (file)
@@ -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"));
             }
         }
index 50e990c..751c0ac 100644 (file)
@@ -116,7 +116,8 @@ public class ServiceSupervision {
     }
 
     private Mono<String> 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();
     }
 }
index 1c4b21d..e8f0ec9 100644 (file)
@@ -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();
     }
 
index 788253c..1fae425 100644 (file)
@@ -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);
     }
 
index 8961615..f26083a 100644 (file)
@@ -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();
     }