WebSocketRegistryListener handles null Session in SessionDisconnectEvent
Fixes gh-77
This commit is contained in:
@@ -84,6 +84,9 @@ public final class WebSocketRegistryListener implements ApplicationListener<Appl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void afterConnectionClosed(String httpSessionId, String wsSessionId) {
|
private void afterConnectionClosed(String httpSessionId, String wsSessionId) {
|
||||||
|
if(httpSessionId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String,WebSocketSession> sessions = httpSessionIdToWsSessions.get(httpSessionId);
|
Map<String,WebSocketSession> sessions = httpSessionIdToWsSessions.get(httpSessionId);
|
||||||
if(sessions != null) {
|
if(sessions != null) {
|
||||||
|
|||||||
@@ -116,6 +116,16 @@ public class WebSocketRegistryListenerTests {
|
|||||||
verify(wsSession,times(0)).close(any(CloseStatus.class));
|
verify(wsSession,times(0)).close(any(CloseStatus.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onApplicationEventConnectDisconnectNullSession() throws Exception {
|
||||||
|
listener.onApplicationEvent(connect);
|
||||||
|
attributes.clear();
|
||||||
|
|
||||||
|
listener.onApplicationEvent(disconnect);
|
||||||
|
|
||||||
|
// no exception
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onApplicationEventConnectConnectDisonnect() throws Exception {
|
public void onApplicationEventConnectConnectDisonnect() throws Exception {
|
||||||
listener.onApplicationEvent(connect);
|
listener.onApplicationEvent(connect);
|
||||||
|
|||||||
Reference in New Issue
Block a user