aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/rest
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-11-09 04:03:10 +0000
committerGerrit Code Review <gerrit@onap.org>2017-11-09 04:03:10 +0000
commit40d761966d4c867007015c894b5dd783edf96cfd (patch)
tree70365857e1de82b7bfd5efadce34677db0267df4 /controlloop/common/model-impl/rest
parentb444334ec9d80aabb6dc7cefae1f2dfd3dd62577 (diff)
parent48c62738bf4c5653e36c6ea1e8e33e649b8526fc (diff)
Merge "Fix SO Request body"
Diffstat (limited to 'controlloop/common/model-impl/rest')
-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) {