From: Dan Timoney Date: Wed, 27 Sep 2017 07:49:39 +0000 (+0000) Subject: Merge "Improve SDNC Sonar coverage" X-Git-Tag: v1.2.1~29 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=c86d7b91c842cfb32a66d1cd377de562920a4178;hp=9fc3345f470867d0df06b071d652641f7af38897;p=sdnc%2Fnorthbound.git Merge "Improve SDNC Sonar coverage" --- diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java index c4d8c52f..522ee7f9 100644 --- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java +++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java @@ -53,23 +53,15 @@ public class VnfSdnUtil extends MdsalHelper { File propFile = new File(ODLHOME.getAbsolutePath() + "/configuration/vnfapi.properties"); String propFileName = propFile.getAbsolutePath(); properties = new Properties(); - InputStream input = null; if (propFile.isFile() && propFile.canRead()) { - try { - input = new FileInputStream(propFile); + try (InputStream input = new FileInputStream(propFile)) { properties.load(input); LOG.info("Loaded properties from " + propFileName ); setYangMappingProperties(properties); + } catch (IOException e) { + LOG.error("Failed to close properties file " + propFileName +"\n",e); } catch (Exception e) { LOG.error("Failed to load properties " + propFileName +"\n",e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - LOG.error("Failed to close properties file " + propFileName +"\n",e); - } - } } } }