From 8819d595b964139540528c51bb7184d481146fcc Mon Sep 17 00:00:00 2001 From: ajay priyadarshi Date: Mon, 12 Mar 2018 18:11:30 +0530 Subject: 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 --- .../internalsvc/impl/JujuAdapter2DriverMgrService.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src') 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; } -- cgit 1.2.3-korg