X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fdmaap%2FDmaapMessageHandler.java;h=19d156488c679b6e807dc9abf81e054c5e1efc8d;hb=5f72ba4fab7f2a8bf54afd41847774e373253f7d;hp=3d5da6297a0e3b12f45ccb6fbfa46eb25f74e36a;hpb=ba50f8809edc7d49a74021e25b4094f4c3174b26;p=nonrtric.git 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 3d5da629..19d15648 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 @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.web.reactive.function.client.WebClientException; import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; @@ -73,15 +74,15 @@ public class DmaapMessageHandler { .flatMap( response -> sendDmaapResponse(response.getBody(), dmaapRequestMessage, response.getStatusCode())); } catch (Exception e) { - logger.warn("Received unparsable message from DMAAP: {}", msg); - return Mono.error(e); // Cannot make any response + String errorMsg = "Received unparsable message from DMAAP: \"" + msg + "\", reason: " + e.getMessage(); + return Mono.error(new ServiceException(errorMsg)); // Cannot make any response } } private Mono> handleAgentCallError(Throwable t, String originalMessage, DmaapRequestMessage dmaapRequestMessage) { logger.debug("Agent call failed: {}", t.getMessage()); - HttpStatus status = HttpStatus.NOT_FOUND; + HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; String errorMessage = t.getMessage(); if (t instanceof WebClientResponseException) { WebClientResponseException exception = (WebClientResponseException) t; @@ -90,7 +91,8 @@ public class DmaapMessageHandler { } else if (t instanceof ServiceException) { status = HttpStatus.BAD_REQUEST; errorMessage = prepareBadOperationErrorMessage(t, originalMessage); - + } else if (!(t instanceof WebClientException)) { + logger.warn("Unexpected exception ", t); } return sendDmaapResponse(errorMessage, dmaapRequestMessage, status) // .flatMap(notUsed -> Mono.empty()); @@ -119,7 +121,6 @@ public class DmaapMessageHandler { } else { return Mono.error(new ServiceException("Not implemented operation: " + operation)); } - } private String payload(DmaapRequestMessage message) {