From e6f50c671627adc43e3aeeb3f3656dc8dfc584dd Mon Sep 17 00:00:00 2001 From: wasala Date: Wed, 23 May 2018 08:27:44 +0200 Subject: Deleted NullPointerException Add logging about status code in DmaapProducer Change-Id: If1e8398cabbee3f0f51fcb007ef02049a7a85c00 Issue-ID: DCAEGEN2-396 Signed-off-by: wasala --- .../ExtendedDmaapConsumerHttpClientImpl.java | 2 +- .../ExtendedDmaapProducerHttpClientImpl.java | 25 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'prh-dmaap-client') diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java index 3bae6989..8d2f82d9 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java @@ -68,7 +68,7 @@ public class ExtendedDmaapConsumerHttpClientImpl { try { return createRequest() .flatMap(this::executeHttpClient); - } catch (NullPointerException | URISyntaxException e) { + } catch (URISyntaxException e) { logger.warn("Exception while executing HTTP request: ", e); } return Optional.empty(); diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java index bea36201..2f96b396 100644 --- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java +++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java @@ -68,7 +68,7 @@ public class ExtendedDmaapProducerHttpClientImpl { try { return createRequest() .flatMap(this::executeHttpClient); - } catch (NullPointerException | URISyntaxException e) { + } catch (URISyntaxException e) { logger.warn("Exception while executing HTTP request: ", e); } return Optional.empty(); @@ -114,16 +114,17 @@ public class ExtendedDmaapProducerHttpClientImpl { } private Optional getDmaapProducerResponseHandler(HttpResponse httpResponse) throws IOException { - final int responseCode = httpResponse.getStatusLine().getStatusCode(); - final HttpEntity responseEntity = httpResponse.getEntity(); + final int responseCode = httpResponse.getStatusLine().getStatusCode(); + logger.info("Status code of operation: {}", responseCode); + final HttpEntity responseEntity = httpResponse.getEntity(); - if (HttpUtils.isSuccessfulResponseCode(responseCode)) { - logger.trace("HTTP response successful."); - return Optional.of("" + responseCode); - } else { - String response = responseEntity != null ? EntityUtils.toString(responseEntity) : ""; - logger.warn("HTTP response not successful : {}", response); - return Optional.of("" + responseCode); - } + if (HttpUtils.isSuccessfulResponseCode(responseCode)) { + logger.trace("HTTP response successful."); + return Optional.of("" + responseCode); + } else { + String response = responseEntity != null ? EntityUtils.toString(responseEntity) : ""; + logger.warn("HTTP response not successful : {}", response); + return Optional.of("" + responseCode); + } } -} +} \ No newline at end of file -- cgit 1.2.3-korg