diff options
author | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 18:11:30 +0530 |
---|---|---|
committer | ajay priyadarshi <ajay.priyadarshi@ril.com> | 2018-03-12 18:11:30 +0530 |
commit | 8819d595b964139540528c51bb7184d481146fcc (patch) | |
tree | 5e0aaf942ad1ac85ec388fb5d9781e247e558043 | |
parent | 7fc1dd800318077f95e59b2c6a4b6ca14399a09b (diff) |
sonar fix: Resource handling modified
try-with resource issues fixed
file name: JujuAdapter2DriverMgrService.java
Change-Id: I82126b1adae3c186bfbf3ce5c17ac8bcb6455449
Issue-ID: VFC-806
Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
-rw-r--r-- | juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java index 7784ba6..12ab241 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapter2DriverMgrService.java @@ -82,17 +82,15 @@ public class JujuAdapter2DriverMgrService implements IJujuAdapter2DriverMgrServi * @throws IOException */ public static String readVimAdapterInfoFromJson() throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; String fileContent = ""; String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator") + "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator") + VIMADAPTER2DRIVERMGR; - 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); @@ -102,14 +100,7 @@ public class JujuAdapter2DriverMgrService implements IJujuAdapter2DriverMgrServi } } catch(FileNotFoundException e) { LOG.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } - } + } return fileContent; } |