Skip to content

Commit 8d9132e

Browse files
committed
Fix #33905: prevent ConcurrentModificationException in ConcurrentModificationException
1 parent 12a6f2d commit 8d9132e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/service/hearbeat/HeartbeatService.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,24 @@ public long getHeartbeatRate() {
120120
@EventListener
121121
public void onSessionDestroyedEvent(HttpSessionDestroyedEvent event) {
122122
// stop every websocket connection started by the session
123-
heartbeatConnectors.get(event.getId()).forEach(HeartbeatConnector::closeConnection);
124-
// remove the session from the map
125123
List<HeartbeatConnector> removedConnectors = heartbeatConnectors.removeAll(event.getId());
124+
for (HeartbeatConnector connector : removedConnectors) {
125+
connector.closeConnection();
126+
}
127+
// remove the connector from the proxy map
126128
for (HeartbeatConnector connector : removedConnectors) {
127129
heartbeatConnectorsByProxyId.remove(connector.proxy.getId(), connector);
128130
}
129131
}
130132

131133
@EventListener
132134
public void onProxyStoppedEvent(ProxyStopEvent event) {
133-
// stop every websocket connection started by this proxy
134-
heartbeatConnectorsByProxyId.get(event.getProxyId()).forEach(HeartbeatConnector::closeConnection);
135-
// remove the session from the map
136-
137135
List<HeartbeatConnector> removedConnectors = heartbeatConnectorsByProxyId.removeAll(event.getProxyId());
136+
// stop every websocket connection started by this proxy
137+
for (HeartbeatConnector connector : removedConnectors) {
138+
connector.closeConnection();
139+
}
140+
// remove the connector from the session map
138141
for (HeartbeatConnector connector : removedConnectors) {
139142
heartbeatConnectors.remove(connector.sessionId, connector);
140143
}

0 commit comments

Comments
 (0)