summaryrefslogtreecommitdiffstats
path: root/juju
diff options
context:
space:
mode:
authorajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-12 18:23:59 +0530
committerajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-12 18:23:59 +0530
commitb7bd16c23152a6abdef4386fc8b4308877a4221e (patch)
tree824fefea3e224eaddb9d2225d74c8d058c43114c /juju
parent8819d595b964139540528c51bb7184d481146fcc (diff)
sonar fix: Resources & Method handling
try-with resource issues fixed file name: PyObjectFactory.java, JujuAdapterMgrService.java, VnfRoa.java Change-Id: I4ac40347e0d053d1fce6299e68dde6629b08badd Issue-ID: VFC-806 Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
Diffstat (limited to 'juju')
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java18
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/juju/PyObjectFactory.java3
-rw-r--r--juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/VnfRoa.java2
3 files changed, 7 insertions, 16 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java
index c803d3e..b7e6094 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/api/internalsvc/impl/JujuAdapterMgrService.java
@@ -80,17 +80,15 @@ public class JujuAdapterMgrService implements IJujuAdapterMgrService {
* @since NFVO 0.5
*/
public static String readJujuAdapterInfoFromJson() throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
String fileContent = "";
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + Constant.JUJUADAPTERINFO;
- 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);
@@ -100,15 +98,7 @@ public class JujuAdapterMgrService implements IJujuAdapterMgrService {
}
} catch(FileNotFoundException e) {
LOG.error(fileName + "is not found!", e, JujuAdapterMgrService.class);
- } finally {
- if(null != ins) {
- ins.close();
- }
-
- if(null != bins) {
- bins.close();
- }
- }
+ }
return fileContent;
}
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/juju/PyObjectFactory.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/juju/PyObjectFactory.java
index 35b4793..a664ed6 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/juju/PyObjectFactory.java
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/juju/PyObjectFactory.java
@@ -42,7 +42,7 @@ public class PyObjectFactory {
* @since NFVO 0.5
*/
public static PyObjectFactory build(String envName) {
- PythonInterpreter interpreter = new PythonInterpreter();
+ try(PythonInterpreter interpreter = new PythonInterpreter()){
interpreter.exec("from jujuclient import Environment");
@@ -50,6 +50,7 @@ public class PyObjectFactory {
PyObject env = environmentClass.__call__();
environmentObj = env.invoke("connect", new PyString(envName));
return new PyObjectFactory();
+ }
}
/**
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/VnfRoa.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/VnfRoa.java
index d7aa919..1f2a97c 100644
--- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/VnfRoa.java
+++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/service/rest/VnfRoa.java
@@ -89,7 +89,7 @@ public class VnfRoa {
@POST
@Path("/vnfminfo")
- public String setVNFMInfo(@Context HttpServletRequest context, @Context HttpServletResponse resp)
+ public static String setVNFMInfo(@Context HttpServletRequest context, @Context HttpServletResponse resp)
throws ServiceException {
JSONObject result = new JSONObject();
result.put("retCode", Constant.REST_SUCCESS);