From 9a983c9067de3c79e6ec85c4715e966929771f67 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 2 Jan 2019 16:22:03 +0530 Subject: Sonar fix: AnsibleMessageParser Fixed sonar issues/code smells across this file Issue-ID: CCSDK-889 Change-Id: I17520284ad7a74573830ca18de37cbcdcf5d6b6d Signed-off-by: Arundathi Patil --- .../ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java index 6e2244ff..427149cc 100644 --- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java +++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java @@ -67,6 +67,7 @@ public class AnsibleMessageParser { private static final String VERSION_OPT_KEY = "Version"; private static final String ACTION_OPT_KEY = "Action"; + private String jsonException = "JSON exception"; private static final Logger LOGGER = LoggerFactory.getLogger(AnsibleMessageParser.class); /** @@ -153,7 +154,7 @@ public class AnsibleMessageParser { ansibleResult = new AnsibleResult(code, msg); } catch (JSONException e) { - LOGGER.error("JSON exception", e); + LOGGER.error(jsonException, e); ansibleResult = new AnsibleResult(600, "Error parsing response = " + input + ". Error = " + e.getMessage()); } return ansibleResult; @@ -171,7 +172,7 @@ public class AnsibleMessageParser { JSONObject postResponse = new JSONObject(input); ansibleResult = parseGetResponseNested(ansibleResult, postResponse); } catch (JSONException e) { - LOGGER.error("JSON exception", e); + LOGGER.error(jsonException, e); ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error parsing response = " + input + ". Error = " + e.getMessage(), ""); } @@ -222,7 +223,7 @@ public class AnsibleMessageParser { finalCode = AnsibleResultCodes.REQ_FAILURE.getValue(); } } catch (JSONException e) { - LOGGER.error("JSON exception", e); + LOGGER.error(jsonException, e); ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue()); ansibleResult.setStatusMessage(String.format( "Error processing response message = %s from host %s", results.getString(host), host)); -- cgit 1.2.3-korg