Skip to content

Commit

Permalink
Fix ConcurrentModificationException when iterating through connection…
Browse files Browse the repository at this point in the history
…s returned by getConnections()
  • Loading branch information
hovis committed Jul 30, 2019
1 parent dc080e0 commit fc30bf2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/java_websocket/server/WebSocketServer.java
Expand Up @@ -279,7 +279,9 @@ public void stop() throws IOException , InterruptedException {
* @since 1.3.8
*/
public Collection<WebSocket> getConnections() {
return Collections.unmodifiableCollection( new ArrayList<WebSocket>(connections) );
synchronized (connections) {
return Collections.unmodifiableCollection( new ArrayList<WebSocket>(connections) );
}
}

public InetSocketAddress getAddress() {
Expand Down

0 comments on commit fc30bf2

Please sign in to comment.