diff options
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; |