From: surya-huawei Date: Thu, 14 Sep 2017 11:12:27 +0000 (+0530) Subject: Fix Sonar Issues X-Git-Tag: v0.1.0~31 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d20f5326f744399c9e741c306043b500991953c8;hp=322886522453c65818199d3575e34d554d3b28ee;p=ccsdk%2Fsli%2Fplugins.git Fix Sonar Issues few critical/major issues in sli/plugins module Issue-Id: CCSDK-87 Change-Id: I4fc33df4ed782670252c9b550349f45b6618c77c Signed-off-by: surya-huawei --- diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 4de4a34d..f2867f5a 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -40,14 +40,14 @@ public class JsonParser { public static Map convertToProperties(String s) throws JSONException { JSONObject json = new JSONObject(s); - Map wm = new HashMap(); + Map wm = new HashMap<>(); Iterator ii = json.keys(); while (ii.hasNext()) { String key1 = ii.next(); wm.put(key1, json.get(key1)); } - Map mm = new HashMap(); + Map mm = new HashMap<>(); while (!wm.isEmpty()) for (String key : new ArrayList<>(wm.keySet())) { diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 13295741..4984d1bc 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -147,8 +147,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { mm = JsonParser.convertToProperties(r.body); if (mm != null) - for (String key : mm.keySet()) - ctx.setAttribute(pp + key, mm.get(key)); + for (Map.Entry entry : mm.entrySet()) + ctx.setAttribute(pp + entry.getKey(), entry.getValue()); } } } catch (Exception e) { @@ -227,7 +227,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected Set getListNameList(Map paramMap) { - Set ll = new HashSet(); + Set ll = new HashSet<>(); for (Map.Entry entry : paramMap.entrySet()) if (entry.getKey().startsWith("listName")) ll.add(entry.getValue()); @@ -473,7 +473,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected SSLContext createSSLContext(Parameters p) { - try { + try (FileInputStream in = new FileInputStream(p.keyStoreFileName)) { System.setProperty("jsse.enableSNIExtension", "false"); System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); @@ -487,7 +487,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { }); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - FileInputStream in = new FileInputStream(p.keyStoreFileName); KeyStore ks = KeyStore.getInstance("PKCS12"); char[] pwd = p.keyStorePassword.toCharArray(); ks.load(in, pwd);