diff options
author | Krishnajinka <kris.jinka@samsung.com> | 2018-07-18 13:28:54 +0900 |
---|---|---|
committer | Krishnajinka <kris.jinka@samsung.com> | 2018-07-18 13:29:36 +0900 |
commit | 026d0d1fac55f0d9df0d45da2cec1b4aa0f6ec78 (patch) | |
tree | 0531eb38ad07be00b430a0f0a7a99a69db45a528 /juju | |
parent | b63ad9f1b13d508ecdcd37822254d47005cb83cc (diff) |
FIX sonar issues
fix sonar issues related with try with resources
Issue-ID: VFC-961
Change-Id: I86c743ef441fdf76ac2b08c8c056647fe95b4dbe
Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'juju')
2 files changed, 15 insertions, 37 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/restclient/RestfulConfigure.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/restclient/RestfulConfigure.java index fc2ad94..eda3da3 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/restclient/RestfulConfigure.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/restclient/RestfulConfigure.java @@ -134,11 +134,10 @@ public class RestfulConfigure { LOG.error(filePath + "isn't exist."); return null; } - BufferedReader reader = null; + final StringBuilder jsonstr = new StringBuilder(); JSONObject jo = null; - try { - reader = new BufferedReader(new FileReader(file)); + try(BufferedReader reader = new BufferedReader(new FileReader(file))) { final ReaderHelper rHelpper = new ReaderHelper(reader); String tempString = null; while((tempString = rHelpper.getLine()) != null) { @@ -147,14 +146,6 @@ public class RestfulConfigure { jo = JSONObject.fromObject(jsonstr.toString()); } catch(final IOException e) { LOG.error("load file exception:" + e); - } finally { - if(reader != null) { - try { - reader.close(); - } catch(final IOException e) { - LOG.error("close error.", e); - } - } } return jo; } diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfo.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfo.java index 24e9adf..38e21af 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfo.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/servicetoken/VNFAuthConfigInfo.java @@ -56,36 +56,23 @@ public class VNFAuthConfigInfo { private VNFAuthConfigInfo() { Properties vnfProp = new Properties(); - InputStream authIn = null; - - try { - if(isVNFProModified(getAuthCofigPath())) { - authIn = new FileInputStream(getAuthCofigPath()); - - vnfProp.load(authIn); - vnfUserName = vnfProp.getProperty("name"); - vnfEncryptedPW = vnfProp.getProperty("value"); - vnfDomain = vnfProp.getProperty("vnfDomain"); - vnfResourceDomain = vnfProp.getProperty("vnfResourceDomain"); - defaultDomain = vnfProp.getProperty("defaultDomain"); - authIn.close(); - } + if(!isVNFProModified(getAuthCofigPath())) { + //cannot find the config path, hence return + LOG.debug("loadAuthConfig can't find config file"); + return; + } + try(InputStream authIn = new FileInputStream(getAuthCofigPath())) { + vnfProp.load(authIn); + vnfUserName = vnfProp.getProperty("name"); + vnfEncryptedPW = vnfProp.getProperty("value"); + vnfDomain = vnfProp.getProperty("vnfDomain"); + vnfResourceDomain = vnfProp.getProperty("vnfResourceDomain"); + defaultDomain = vnfProp.getProperty("defaultDomain"); } catch(IOException e) { LOG.error("loadAuthConfig can't find config file>> e = {}", e); - } finally { - try { - if(authIn != null) { - - authIn.close(); - } - } catch(IOException e) { - LOG.error("loadAuthConfig can't find config file>> e = {}", e); - } - - } - } + } private String getAuthCofigPath() { return AUTH_CONFIG_FILE; |