summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/rest/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl/rest/src/main/java')
-rw-r--r--controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
index 9ea480981..e2d140c03 100644
--- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
+++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java
@@ -79,19 +79,21 @@ public final class RESTManager {
post.setEntity(input);
HttpResponse response = client.execute(post);
-
- String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
- logger.debug("HTTP POST Response Body:");
- logger.debug(returnBody);
-
- return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
- } catch (IOException e) {
+ if (response != null) {
+ String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+ logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
+
+ return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
+ } else {
+ logger.error("Response from {} is null", url);
+ return null;
+ }
+ } catch (Exception e) {
logger.error("Failed to POST to {}",url,e);
-
return null;
- }
-
+ }
}
public static Pair<Integer, String> get(String url, String username, String password, Map<String, String> headers) {