aboutsummaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider/src/main/java
diff options
context:
space:
mode:
authorsurya-huawei <a.u.surya@huawei.com>2017-09-21 11:43:59 +0530
committersurya-huawei <a.u.surya@huawei.com>2017-09-21 11:47:59 +0530
commitfe6c174b98f888d214c7a7f9a87957592a04ec6f (patch)
treef3d2da66828ad29a232e747487ed82260558e981 /generic-resource-api/provider/src/main/java
parent046922b6bd05cfcc4759985368a858f0a7b25cd9 (diff)
Change "try" to try-with-resources
One major issue in sdnc/northbound module *This is done for a guaranteed closing of resource and not worrying about finally block to close it Issue-Id: CCSDK-87 Change-Id: Ic6ea871cb9fb61cbce24b61d7c434d3404570ae7 Signed-off-by: surya-huawei <a.u.surya@huawei.com>
Diffstat (limited to 'generic-resource-api/provider/src/main/java')
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java16
1 files changed, 4 insertions, 12 deletions
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
index 5b534bbc..6e6da0e4 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java
@@ -22,23 +22,15 @@ public class GenericResourceApiUtil extends MdsalHelper {
File file = new File(PROPERTIES_FILE);
properties = new Properties();
- InputStream input = null;
- if (file.isFile() && file.canRead()) {
- try {
- input = new FileInputStream(file);
+ if(file.isFile() && file.canRead()) {
+ try(InputStream input = new FileInputStream(file)){
properties.load(input);
LOG.info("Loaded properties from " + PROPERTIES_FILE );
setYangMappingProperties(properties);
+ } catch (IOException e) {
+ LOG.error("Failed to close properties file " + PROPERTIES_FILE +"\n",e);
} catch (Exception e) {
LOG.error("Failed to load properties " + PROPERTIES_FILE +"\n",e);
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- LOG.error("Failed to close properties file " + PROPERTIES_FILE +"\n",e);
- }
- }
}
}
}