Skip to content

Commit

Permalink
Fix ConcurrentModificationException when iterating through conne… (#922)
Browse files Browse the repository at this point in the history
Fix ConcurrentModificationException when iterating through connection…
  • Loading branch information
marci4 committed Aug 12, 2019
2 parents dc080e0 + fc30bf2 commit 8fcd4d1
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 8fcd4d1

Please sign in to comment.