Describe the bug
ConcurrentModificationException when looping connections returned by getConnections() and a connection is created/removed elsewhere at the same time.
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
at java.util.HashMap$KeyIterator.next(HashMap.java:845)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at java.util.ArrayList.<init>(ArrayList.java:151)
at org.java_websocket.server.WebSocketServer.getConnections(WebSocketServer.java:289)
...
To Reproduce
Steps to reproduce the behavior:
- . Create a thread that requests connections via getConnections() and iterates over the connections (say gathering stats). Run all of that in a loop.
- .. Whilst that thread is running connect and disconnect from the WebSocket server using a WebSocket client.
- ... Should see an intermittent race condition leading to a ConcurrentModificationException
Expected behavior
No ConcurrentModificationException
Environment(please complete the following information):
- Version used: 1.3.9 & 1.4.0
- Java version: 1.8
- Operating System and version: MacOS / Linux
- Endpoint Name and version: Chrome/Safari/Firefox
Describe the bug
ConcurrentModificationException when looping connections returned by getConnections() and a connection is created/removed elsewhere at the same time.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No ConcurrentModificationException
Environment(please complete the following information):