diff options
author | eramkve <ram.krishna.verma@ericsson.com> | 2018-03-16 15:44:07 +0000 |
---|---|---|
committer | eramkve <ram.krishna.verma@ericsson.com> | 2018-03-20 15:28:04 +0000 |
commit | eef3c224cb6cad4b82a96938ade1e42ca881eea2 (patch) | |
tree | 37fc08a9b229e5634c0ffb983227f9f563ac7766 /ONAP-PDP/src/main/java | |
parent | 44fd25bcbb86f8600ec88eeeac6bb8312672c470 (diff) |
Fix all bugs reported by Sonar in policy/engine
Code fixes for 27 bugs reported by Sonar in policy/engine
Change-Id: I96da96b38a2e2954ec549e5cdf6ed3ad1d76722c
Issue-ID: POLICY-662
Signed-off-by: eramkve <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'ONAP-PDP/src/main/java')
-rw-r--r-- | ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java b/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java index c6a889821..5fde0adf3 100644 --- a/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java +++ b/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java @@ -240,6 +240,7 @@ public class FindAction { Pattern pattern = Pattern.compile("\\$([a-zA-Z0-9.:]*)"); Matcher match = pattern.matcher(configURL); StringBuffer sb = new StringBuffer(); + JsonReader jsonReader = null; while (match.find()) { LOGGER.info("Found Macro : " + match.group(1)); String replaceValue = matchValues.get(match.group(1)); @@ -292,7 +293,7 @@ public class FindAction { connection = configURL.openConnection(); // InputStream in = connection.getInputStrem(); // LOGGER.info("The Body Content is : " + IOUtils.toString(in)); - JsonReader jsonReader = Json.createReader(connection.getInputStream()); + jsonReader = Json.createReader(connection.getInputStream()); StringEntity input = new StringEntity(jsonReader.readObject().toString()); input.setContentType("application/json"); postRequest.setEntity(input); @@ -312,6 +313,13 @@ public class FindAction { LOGGER.error(e.getMessage() +e); response = e.getMessage(); } finally { + if(jsonReader != null) { + try { + jsonReader.close(); + } catch (Exception e) { + LOGGER.error("Exception Occured while closing the JsonReader"+e); + } + } httpClient.getConnectionManager().shutdown(); } } else if(matchValues.get("method").equalsIgnoreCase("PUT")) { @@ -330,7 +338,7 @@ public class FindAction { connection = configURL.openConnection(); //InputStream in = connection.getInputStream(); //LOGGER.info("The Body Content is : " + IOUtils.toString(in)); - JsonReader jsonReader = Json.createReader(connection.getInputStream()); + jsonReader = Json.createReader(connection.getInputStream()); StringEntity input = new StringEntity(jsonReader.readObject().toString()); input.setContentType("application/json"); putRequest.setEntity(input); @@ -349,6 +357,13 @@ public class FindAction { LOGGER.error(e.getMessage() +e); response = e.getMessage(); }finally { + if(jsonReader != null) { + try { + jsonReader.close(); + } catch (Exception e) { + LOGGER.error("Exception Occured while closing the JsonReader"+e); + } + } httpClient.getConnectionManager().shutdown(); } } |