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

java.util.ConcurrentModificationException on broadcast #961

Closed
papirosko opened this issue Jan 8, 2020 · 4 comments
Closed

java.util.ConcurrentModificationException on broadcast #961

papirosko opened this issue Jan 8, 2020 · 4 comments

Comments

@papirosko
Copy link

Hi. Broadcasting uses connections without synchronization:

	/**
	 * Send a text to all connected endpoints
	 * @param text the text to send to the endpoints
	 */
	public void broadcast(String text) {
		broadcast( text, connections );
	}

even trying to override this method with:

  override void broadcast(String: text) = {
    broadcast( text, getConnections() );
  }

will lead to

java.util.ConcurrentModificationException: null
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)
	at java.util.HashMap$KeyIterator.next(HashMap.java:1469)
	at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
	at java.util.ArrayList.<init>(ArrayList.java:178)
	at org.java_websocket.server.WebSocketServer.getConnections(WebSocketServer.java:282)
@papirosko
Copy link
Author

as a workaround, use new CopyOnWriteArraySet() in websocket constructor.

@izamata01
Copy link

izamata01 commented Jan 8, 2020 via email

@marci4
Copy link
Collaborator

marci4 commented Jan 8, 2020

Hello,
Could you try the latest snapshot?
Should be fixed with #922.

Best regards,
Marcel

@marci4
Copy link
Collaborator

marci4 commented Jan 20, 2020

Closing this issue as duplicate!

Best regards,
Marcel

@marci4 marci4 closed this as completed Jan 20, 2020
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

3 participants