Skip to content

ConcurrentModificationException in SimpleBrokerMessageHandler [SPR-12665] #17264

Closed
@spring-projects-issues

Description

@spring-projects-issues

Piotr Leśniak opened SPR-12665 and commented

During invocation of SimpMessageSendingOperations::convertAndSend method ConcurrentModificationException occures. It happens very rarely (I found out about this bug by checking logs from production, I haven't seen it in application), probably when invocation of this method happens simultaneously with closing webSocket on a client.

Here's a stack:

org.springframework.messaging.MessageDeliveryException: Failed to handle message to ExecutorSubscribableChannel[brokerChannel] in SimpleBroker[DefaultSubscriptionRegistry[cache[2 destination(s)], registry[2 sessions]]]; nested exception is java.util.ConcurrentModificationException
	at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:180) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.support.ExecutorSubscribableChannel.sendInternal(ExecutorSubscribableChannel.java:93) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:107) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.support.AbstractMessageChannel.send(AbstractMessageChannel.java:94) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.simp.SimpMessagingTemplate.sendInternal(SimpMessagingTemplate.java:185) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.simp.SimpMessagingTemplate.doSend(SimpMessagingTemplate.java:160) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.simp.SimpMessagingTemplate.doSend(SimpMessagingTemplate.java:47) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:133) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:113) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:108) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at 
.... [our application stack leading to convertAndSend on SimpMessageSendingOperations object]
Caused by: java.util.ConcurrentModificationException: null
	at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:394) ~[na:1.7.0_55]
	at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:405) ~[na:1.7.0_55]
	at org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler.sendMessageToSubscribers(SimpleBrokerMessageHandler.java:227) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler.handleMessageInternal(SimpleBrokerMessageHandler.java:183) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler.handleMessage(AbstractBrokerMessageHandler.java:180) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:172) ~[spring-messaging-4.1.0.RELEASE.jar:4.1.0.RELEASE]
	... 24 common frames omitted

Can it be related to this #16377 bug?


Affects: 4.1 GA

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions