Author: remm
Date: Fri Jun 12 16:42:31 2015
New Revision: 1685128
URL: http://svn.apache.org/r1685128
Log:
57974: Key the open session map on the endpoint instance rather than endpoint
class. Will backport if it doesn't cause issues.
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1685128&r1=1685127&r2=1685128&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Jun 12
16:42:31 2015
@@ -415,7 +415,7 @@ public class WsSession implements Sessio
@Override
public Set<Session> getOpenSessions() {
checkState();
- return webSocketContainer.getOpenSessions(localEndpoint.getClass());
+ return webSocketContainer.getOpenSessions(localEndpoint);
}
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1685128&r1=1685127&r2=1685128&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Fri
Jun 12 16:42:31 2015
@@ -83,7 +83,7 @@ public class WsWebSocketContainer implem
private final Object asynchronousChannelGroupLock = new Object();
private final Log log = LogFactory.getLog(WsWebSocketContainer.class);
- private final Map<Class<?>, Set<WsSession>> endpointSessionMap =
+ private final Map<Endpoint, Set<WsSession>> endpointSessionMap =
new HashMap<>();
private final Map<WsSession,WsSession> sessions = new
ConcurrentHashMap<>();
private final Object endPointSessionMapLock = new Object();
@@ -370,8 +370,6 @@ public class WsWebSocketContainer implem
protected void registerSession(Endpoint endpoint, WsSession wsSession) {
- Class<?> endpointClazz = endpoint.getClass();
-
if (!wsSession.isOpen()) {
// The session was closed during onOpen. No need to register it.
return;
@@ -380,10 +378,10 @@ public class WsWebSocketContainer implem
if (endpointSessionMap.size() == 0) {
BackgroundProcessManager.getInstance().register(this);
}
- Set<WsSession> wsSessions = endpointSessionMap.get(endpointClazz);
+ Set<WsSession> wsSessions = endpointSessionMap.get(endpoint);
if (wsSessions == null) {
wsSessions = new HashSet<>();
- endpointSessionMap.put(endpointClazz, wsSessions);
+ endpointSessionMap.put(endpoint, wsSessions);
}
wsSessions.add(wsSession);
}
@@ -411,7 +409,7 @@ public class WsWebSocketContainer implem
}
- Set<Session> getOpenSessions(Class<?> endpoint) {
+ Set<Session> getOpenSessions(Endpoint endpoint) {
HashSet<Session> result = new HashSet<>();
synchronized (endPointSessionMapLock) {
Set<WsSession> sessions = endpointSessionMap.get(endpoint);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]