X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FConfigPolicy.java;h=48eb784a7c2219d48b07557122c10aac5a7ce0e9;hb=eef3c224cb6cad4b82a96938ade1e42ca881eea2;hp=adcffe93907c59a8923acef037503563d7d135c0;hpb=44fd25bcbb86f8600ec88eeeac6bb8312672c470;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java index adcffe939..48eb784a7 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java @@ -80,17 +80,24 @@ public class ConfigPolicy extends Policy { // Saving the Configurations file at server location for config policy. protected void saveConfigurations(String policyName) { + BufferedWriter bw = null; try { String fileName = getConfigFile(policyName); - FileWriter fw = new FileWriter(CONFIG_HOME + File.separator + fileName); - BufferedWriter bw = new BufferedWriter(fw); + bw = new BufferedWriter(new FileWriter(CONFIG_HOME + File.separator + fileName)); bw.write(configBodyData); - bw.close(); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Configuration is succesfully saved"); + LOGGER.debug("Configuration is succesfully saved"); } } catch (IOException e) { LOGGER.error("Exception Occured while writing Configuration Data"+e); + } finally { + if(bw != null){ + try { + bw.close(); + } catch (Exception e) { + LOGGER.error("Exception Occured while closing the BufferedWriter"+e); + } + } } }