From 8a2cc38d7e8a3c259d3872655732a15051022c4e Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 14 Sep 2017 11:38:05 +0530 Subject: Fix critical issues few critical/major issues in core/sli module Issue-Id: CCSDK-87 Change-Id: Ib7ef026ecb7fcf658ea8fc66ad5d9b739f02c55b Signed-off-by: surya-huawei --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 8ab308ebc..60dd6b46a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -65,23 +65,13 @@ public class MdsalHelper { public static void loadProperties(String propertiesFile) { File file = new File(propertiesFile); Properties properties = new Properties(); - InputStream input = null; if (file.isFile() && file.canRead()) { - try { - input = new FileInputStream(file); - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); + try (InputStream input = new FileInputStream(file)) { + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - LOG.error("Failed to close properties file " + propertiesFile + "\n", e); - } - } + LOG.error("Failed to load properties " + propertiesFile + "\n", e); } }else{ LOG.error("Failed to load the properties file " + propertiesFile + "\n"); @@ -127,7 +117,7 @@ public class MdsalHelper { for (int i = 0; i < fromList.size(); i++) { toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); } - props.setProperty(pfx + "_length", "" + fromList.size()); + props.setProperty(pfx + "_length", Integer.toString(fromList.size())); } else if (isYangGenerated(fromClass)) { // Class is yang generated. -- cgit 1.2.3-korg