Merge "Policy:Blocker"
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 13 Mar 2018 16:19:52 +0000 (16:19 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 13 Mar 2018 16:19:52 +0000 (16:19 +0000)
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ActionPolicy.java

index 91530c7..43eb434 100644 (file)
@@ -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());
             }