From: Manamohan Satapathy Date: Tue, 13 Mar 2018 08:59:51 +0000 (+0530) Subject: Policy:Blocker X-Git-Tag: v1.2.0~63^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=5242bcd284b8ea10528b96bb3f70f921d998aee1;hp=0e75793d9c09b31b783556212380bb112f50219a;p=policy%2Fengine.git Policy:Blocker Use try-with-resources to close this JarFile:L264 L265 Issue-ID: POLICY-683 Sonar Link: https://sonar.onap.org/issues?myIssues=true&open=AWF91iwf8TZzbCgU6arv&resolved=false Location:ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java Change-Id: Ie9adb5b50dbb61c923bf73fa107fd19366f24304 Signed-off-by: Manamohan Satapathy --- diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java index 91530c7af..43eb4348e 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java @@ -256,15 +256,12 @@ public class ActionPolicy extends Policy { // Saving the json Configurations file if exists at server location for action policy. private void saveActionBody(String policyName, String actionBodyData) { - try { if(policyName.endsWith(".xml")){ policyName = policyName.replace(".xml", ""); } File file = new File(ACTION_HOME+ File.separator + policyName + ".json"); - FileWriter fw = new FileWriter(file.getAbsoluteFile()); - BufferedWriter bw = new BufferedWriter(fw); + try(BufferedWriter bw = new BufferedWriter(new FileWriter(file.getAbsoluteFile()))) { bw.write(actionBodyData); - bw.close(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Action Body is succesfully saved at " + file.getAbsolutePath()); }