From: grabinsk Date: Fri, 7 Jun 2019 10:21:44 +0000 (+0200) Subject: handle 404 from aai X-Git-Tag: 1.3.1~27 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F89631%2F1;p=dcaegen2%2Fservices%2Fprh.git handle 404 from aai (parsing response body from aai should not be attempted if there is no 2xx response) Change-Id: Iedc9daa65895600d826ac808784b3c6803a6dab4 Issue-ID: DCAEGEN2-1601 Signed-off-by: grabinsk --- diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java index 8548ffe8..e09322d3 100644 --- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java +++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java @@ -55,16 +55,22 @@ public class AaiHttpClientConfig { public AaiHttpClient getServiceInstanceClient() { return createLazyConfigClient( (config, client) -> new AaiGetServiceInstanceClient(config, client) - .map(httpResponse -> httpResponse.bodyAsJson(StandardCharsets.UTF_8, - PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class))); + .map(httpResponse -> { + httpResponse.throwIfUnsuccessful(); + return httpResponse.bodyAsJson(StandardCharsets.UTF_8, + PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class); + })); } @Bean public AaiHttpClient getGetClient() { return createLazyConfigClient( (config, client) -> new AaiHttpGetClient(config, client) - .map(httpResponse -> httpResponse.bodyAsJson(StandardCharsets.UTF_8, - PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class))); + .map(httpResponse -> { + httpResponse.throwIfUnsuccessful(); + return httpResponse.bodyAsJson(StandardCharsets.UTF_8, + PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class); + })); } private AaiHttpClient createLazyConfigClient(