spring-projects / spring-integration

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)
http://projects.spring.io/spring-integration/
Apache License 2.0
1.53k stars 1.1k forks source link

Concurrent modification exception in PayloadTypeMatchingHandlerMethodResolver [INT-624] #4634

Closed spring-operator closed 15 years ago

spring-operator commented 15 years ago

Stéphane Cusin opened INT-624 and commented

When we start you application with a big load of message (500/s) with 16 consumers threads on a jms queue we have a java.util.ConcurrentModificationException.

In this class: org.springframework.integration.handler.PayloadTypeMatchingHandlerMethodResolver the access of methodMap is not Thread safe !!!

[25/03/09 17:01:34.701] FATAL [Thread-131] [] [IntegrationMessageListener] - Process message error. org.springframework.integration.message.MessageHandlingException: error occurred in message handler [ServiceActivator for [org.springframework.integration.handler.MessageMappingMethodInvoker@1e4a649]] at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:54) at org.springframework.integration.dispatcher.AbstractDispatcher.sendMessageToHandler(AbstractDispatcher.java:75) at org.springframework.integration.dispatcher.SimpleDispatcher.dispatch(SimpleDispatcher.java:45) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:56) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:116) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:94) at com.swissquote.info.apps.platform.bus.jms.IntegrationMessageListener.onMessage(IntegrationMessageListener.java:125) at com.atomikos.jms.extra.MessageConsumerSession$ReceiverThread.run(MessageConsumerSession.java:473) Caused by: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$EntryIterator.next(HashMap.java:834) at java.util.HashMap$EntryIterator.next(HashMap.java:832) at java.util.HashMap$AbstractManagedEntriesIterator.nextEntry(HashMap/java:750) at java.util.HashMap$AbstractManagedEntriesIterator.next(HashMap/java:741) at java.util.HashMap$AbstractManagedEntriesIterator.nextEntry(HashMap/java:750) at java.util.HashMap$AbstractManagedEntriesIterator.next(HashMap/java:741) at java.util.HashMap$KeysIterator.next(HashMap/java:791) at org.springframework.integration.handler.PayloadTypeMatchingHandlerMethodResolver.findClosestMatch(PayloadTypeMatchingHandlerMethodResolver.java:121) at org.springframework.integration.handler.PayloadTypeMatchingHandlerMethodResolver.resolveHandlerMethod(PayloadTypeMatchingHandlerMethodResolver.java:57) at org.springframework.integration.handler.MessageMappingMethodInvoker.invokeMethod(MessageMappingMethodInvoker.java:97) at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:49) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:90) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:48) ... 7 more


Affects: 1.0.2

Attachments:

spring-operator commented 15 years ago

Mark Fisher commented

The methodMap is now a ConcurrentHashMap: https://fisheye.springsource.org/changelog/spring-integration/?cs=2069

Please test your example that was previously failing against the SVN trunk if possible.

Build status: http://build.springframework.org/browse/INT-TRUNK-1570/

spring-operator commented 15 years ago

Stéphane Cusin commented

I can reproduce the probleme only in the production environment, but I have reproduce the bug with JUnit test. See the attach zip file.

To reproduce the bug I have make a copy of the class and add this line Thread.yield(); in findClosestMatch method.

The fix correct the bug. Thank you.

spring-operator commented 15 years ago

Mark Fisher commented

Confirmed fix with test case.

spring-operator commented 15 years ago

Mark Fisher commented

This will be included in 1.0.2.SR1