diff options
author | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 18:00:54 +0530 |
---|---|---|
committer | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 18:00:54 +0530 |
commit | 7fc1dd800318077f95e59b2c6a4b6ca14399a09b (patch) | |
tree | 3cc2b310924525a03457cd4bfbc23ff760311109 /juju/juju-vnfmadapter/Juju-vnfmadapterService | |
parent | 1b59ac99df3c4a30ec814fb7c311b97fec2884d5 (diff) |
sonar fix: Rsrc handling in JujuClientManager
try-with resource issues fixed
file name: JujuClientManager.java
Change-Id: Id547af46419cc0bb75ca29af324ffff2570d83b4
Issue-ID: VFC-805
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
Diffstat (limited to 'juju/juju-vnfmadapter/Juju-vnfmadapterService')
-rw-r--r-- | juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/adapter/impl/JujuClientManager.java | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/adapter/impl/JujuClientManager.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/adapter/impl/JujuClientManager.java index fee0f28..6753108 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/adapter/impl/JujuClientManager.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/adapter/impl/JujuClientManager.java @@ -167,16 +167,13 @@ public class JujuClientManager implements IJujuClientManager { * @since NFVO 0.5 */ public static String readJujuConfigInfo() { - InputStream ins = null; - - BufferedInputStream bins = null; String fileContent = null; String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator") + "etc" + System.getProperty("file.separator") + "conf" + System.getProperty("file.separator") + "juju_conf.json"; - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); + try ( + InputStream ins = new FileInputStream(fileName); + BufferedInputStream bins = new BufferedInputStream(ins)){ byte[] contentByte = new byte[ins.available()]; int num = bins.read(contentByte); @@ -186,17 +183,7 @@ public class JujuClientManager implements IJujuClientManager { } } catch (Exception e) { LOG.error(fileName + "is not found!", e); - } finally { - try { - if (ins != null) { - ins.close(); - } - if (bins != null) { - bins.close(); - } - } catch (IOException e) { - } - } + } return fileContent; } private JSONObject changeDir(String charmPath) { |