From c4948c141a68433b4ba9eca167622816dcd10fa1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 28 Jun 2016 15:25:08 +0300 Subject: fix session closing --- src/main/java/com/juick/ws/WebsocketComponent.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/juick/ws') diff --git a/src/main/java/com/juick/ws/WebsocketComponent.java b/src/main/java/com/juick/ws/WebsocketComponent.java index 7399c298..8ccccb3b 100644 --- a/src/main/java/com/juick/ws/WebsocketComponent.java +++ b/src/main/java/com/juick/ws/WebsocketComponent.java @@ -103,9 +103,12 @@ public class WebsocketComponent extends TextWebSocketHandler { @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { synchronized (clients) { - clients.stream().filter(c -> c.session.getId().equals(session.getId())).forEach(c -> { - logger.info(String.format("session %s closed with status %s", c.clientName, status.getCode())); - clients.remove(c); + clients.removeIf(c -> { + if (c.session.equals(session)) { + logger.info(String.format("session from %s closed with status %d", c.clientName, status.getCode())); + return true; + } + return false; }); } -- cgit v1.2.3