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 in SimpleBrokerMessageHandler [SPR-12665] #17264

Closed
spring-issuemaster opened this issue Jan 26, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Jan 26, 2015

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:

  • #17777 ConcurrentModificationException when calling SimpMessagingTemplate.convertAndSend
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 2, 2015

Rossen Stoyanchev commented

Although DefaultSubscriptionRegistry maintained separate "update" and "access" caches to ensure that findSubscriptions returns a safe to iterate map, there was a bug in the addSubscriptions method that mistakenly used the original map for the "update" cache. This has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.