diff options
author | 2017-09-22 19:14:49 +0530 | |
---|---|---|
committer | 2017-09-25 08:27:59 +0000 | |
commit | e8058c88413de8e648a4c85385b1ec798d31c888 (patch) | |
tree | 6834f152ada856ac0946c0a76282532a8d1b73f3 /vnfapi/provider/src/main | |
parent | 15cfb74776aafab9319a859f8b7cce9de23df209 (diff) |
Change "try" to try-with-resources
One major issue in sdnc/northbound module
*This is done for a guaranteed closing of resource
and avoiding the finally block
Issue-Id: CCSDK-87
Change-Id: I3ab9119f0b10f47d16864aa3619cc54e069bb9de
Signed-off-by: surya-huawei <a.u.surya@huawei.com>
Diffstat (limited to 'vnfapi/provider/src/main')
-rw-r--r-- | vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java | 14 |
1 files changed, 3 insertions, 11 deletions
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); - } - } } } } |