Skip to content

java.util.ConcurrentModificationException on broadcast #961

@papirosko

Description

@papirosko

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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions