diff options
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java')
-rw-r--r-- | ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java | 15 |
1 files changed, 12 insertions, 3 deletions
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 b808e5882..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,15 +80,24 @@ public class ConfigPolicy extends Policy { // Saving the Configurations file at server location for config policy. protected void saveConfigurations(String policyName) { - - String fileName = getConfigFile(policyName); - try(BufferedWriter bw = new BufferedWriter(new FileWriter(CONFIG_HOME + File.separator + fileName))) { + BufferedWriter bw = null; + try { + String fileName = getConfigFile(policyName); + bw = new BufferedWriter(new FileWriter(CONFIG_HOME + File.separator + fileName)); bw.write(configBodyData); if (LOGGER.isDebugEnabled()) { 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); + } + } } } |