Fix all bugs reported by Sonar in policy/engine
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / components / MicroServiceConfigPolicy.java
index b0e48a7..e021211 100644 (file)
@@ -88,13 +88,11 @@ public class MicroServiceConfigPolicy extends Policy {
 
        //save configuration of the policy based on the policyname
        private void saveConfigurations(String policyName, String jsonBody) {
-               try {
-                       if(policyName.endsWith(".xml")){
-                               policyName = policyName.replace(".xml", "");
-                       }
-                       PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName +".json");
+               if(policyName.endsWith(".xml")){
+                   policyName = policyName.replace(".xml", "");
+               }
+               try (PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName +".json")){
                        out.println(jsonBody);
-                       out.close();
                } catch (Exception e) {
                        LOGGER.error("Exception Occured While writing Configuration data"+e);
                }