Skip to content

Commit fc30bf2

Browse files
committed
Fix ConcurrentModificationException when iterating through connections returned by getConnections()
1 parent dc080e0 commit fc30bf2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/java_websocket/server/WebSocketServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ public void stop() throws IOException , InterruptedException {
279279
* @since 1.3.8
280280
*/
281281
public Collection<WebSocket> getConnections() {
282-
return Collections.unmodifiableCollection( new ArrayList<WebSocket>(connections) );
282+
synchronized (connections) {
283+
return Collections.unmodifiableCollection( new ArrayList<WebSocket>(connections) );
284+
}
283285
}
284286

285287
public InetSocketAddress getAddress() {

0 commit comments

Comments
 (0)