summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core
diff options
context:
space:
mode:
authorPawel <pawel.kasperkiewicz@nokia.com>2019-05-22 09:15:32 -0400
committerPawel <pawel.kasperkiewicz@nokia.com>2019-05-22 09:15:32 -0400
commita7073ff8b7f0cd1a211bbe2ba0954d4ec949404f (patch)
tree4af70ccb1eabc118306cc21cbb54d241c1b32fc7 /ecomp-sdk/epsdk-core
parent68eabf669e4c83bd669286900e8a6f77e4009f29 (diff)
Fix sonar issues in WebRTCSocket
Issue-ID: PORTAL-587 Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com> Change-Id: I3087714f7d3b8b012a8b93b1ac92b88d33cd910d
Diffstat (limited to 'ecomp-sdk/epsdk-core')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
index ed8e89e3..dc18c3be 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java
@@ -33,13 +33,14 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.core.web.socket;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
@@ -55,8 +56,9 @@ public class WebRTCSocket {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebRTCSocket.class);
- private final static Map<String, Hashtable<String, Object[]>> channelMap = new Hashtable<String, Hashtable<String, Object[]>>();
- private final Map<String, String> sessionMap = new Hashtable<String, String>();
+ private static final Map<String, HashMap<String, Object[]>> channelMap = new HashMap<>();
+ private static final String MESSAGE_FAILED = "mesage failed";
+ private final Map<String, String> sessionMap = new HashMap<>();
private final ObjectMapper mapper = new ObjectMapper();
@OnMessage
@@ -69,11 +71,11 @@ public class WebRTCSocket {
if (isOpen != null && (Boolean) isOpen) {
String channel = (String) jsonObject.get("channel");
Object value = channelMap.get(channel);
- Hashtable<String, Object[]> sourceDestMap;
+ HashMap<String, Object[]> sourceDestMap;
if (value == null)
- sourceDestMap = new Hashtable<>();
+ sourceDestMap = new HashMap<>();
else
- sourceDestMap = (Hashtable<String, Object[]>) value;
+ sourceDestMap = (HashMap<String, Object[]>) value;
sourceDestMap.put(session.getId(), new Object[] { session });
channelMap.put(channel, sourceDestMap);
@@ -81,7 +83,7 @@ public class WebRTCSocket {
}
} catch (Exception je) {
- logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je);
}
try {
@@ -97,26 +99,27 @@ public class WebRTCSocket {
else
channel = (String) jsonObject.get("channel");
} catch (Exception json) {
- logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", json);
+ logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, json);
}
- Hashtable<String, Object[]> sourceDestMap = channelMap.get(channel);
+ HashMap<String, Object[]> sourceDestMap = channelMap.get(channel);
if (sourceDestMap != null)
- for (String id : sourceDestMap.keySet()) {
- if (!id.equals(session.getId())) {
- Session otherSession = (Session) (sourceDestMap.get(id))[0];
+ for (Entry<String, Object[]> entry : sourceDestMap.entrySet()){
+
+ if (!entry.getKey().equals(session.getId())) {
+ Session otherSession = (Session) (entry.getValue())[0];
if (otherSession.isOpen())
otherSession.getBasicRemote().sendText(mapper.writeValueAsString(dataObj));
}
}
} catch (Exception je) {
- logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je);
}
} catch (Exception je) {
- logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je);
+ logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je);
}
}