From 78287ab8b72352a91e6626c3f95fecc32b7b54a3 Mon Sep 17 00:00:00 2001 From: "Hockla, Ali (ah999m)" Date: Wed, 25 Oct 2017 12:03:48 -0500 Subject: Fix sonar blocker for SOManager Issue-ID: POLICY-385 Change-Id: I142877a3173a028738b1aa2aea9521f6208bab38 Signed-off-by: Hockla, Ali (ah999m) --- .../src/main/java/org/onap/policy/so/SOManager.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'controlloop/common/model-impl/so/src/main/java') diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java index 93c3f4c57..c6d0994ad 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java @@ -162,21 +162,24 @@ public final class SOManager { .setPrettyPrinting() .create(); - String msoJson = gsonPretty.toJson(request); + String soJson = gsonPretty.toJson(request); - SOResponse mso = new SOResponse(); - netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), msoJson); - Pair httpResponse = RESTManager.post(url, "policy", "policy", headers, "application/json", msoJson); - netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b); + SOResponse so = new SOResponse(); + netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, System.lineSeparator(), soJson); + Pair httpResponse = RESTManager.post(url, "policy", "policy", headers, "application/json", soJson); if (httpResponse != null) { + netLogger.info("[IN|{}|{}|]{}{}", url, "SO", System.lineSeparator(), httpResponse.b); + Gson gson = new Gson(); - mso = gson.fromJson(httpResponse.b, SOResponse.class); - mso.httpResponseCode = httpResponse.a; + so = gson.fromJson(httpResponse.b, SOResponse.class); + so.httpResponseCode = httpResponse.a; + } else { + logger.error("SO Response returned null."); } - wm.insert(mso); - logger.info("SOResponse inserted " + gsonPretty.toJson(mso)); + wm.insert(so); + logger.info("SOResponse inserted " + gsonPretty.toJson(so)); } }); } -- cgit 1.2.3-korg