Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException when looping connections #921

Closed
hovis opened this issue Jul 30, 2019 · 1 comment
Closed

ConcurrentModificationException when looping connections #921

hovis opened this issue Jul 30, 2019 · 1 comment

Comments

@hovis
Copy link
Contributor

hovis commented Jul 30, 2019

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:

  1. . Create a thread that requests connections via getConnections() and iterates over the connections (say gathering stats). Run all of that in a loop.
  2. .. Whilst that thread is running connect and disconnect from the WebSocket server using a WebSocket client.
  3. ... 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
@marci4
Copy link
Collaborator

marci4 commented Aug 12, 2019

Fixed with #922

@marci4 marci4 closed this as completed Aug 12, 2019
@marci4 marci4 added this to the Release 1.4.1 milestone Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants