Well you have an array 'packet' and if "packet" is concurrently modified elsewhere, then you get this exception. In your case it seems like when toString() is executed the contents of the 'packet' are being modified by another thread.
Well you have an array 'packet' and if "packet" is concurrently modified elsewhere, then you get this exception. In your case it seems like when toString() is executed the contents of the 'packet' are being modified by another thread.
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
I removed aspects, still having exception:
Code:Caused by: java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761) at java.util.LinkedList$ListItr.next(LinkedList.java:696) at splitter.MsgTypeSplitter.splitMessage(MsgTypeSplitter.java:25) at org.springframework.integration.splitter.AbstractMessageSplitter.handleRequestMessage(AbstractMessageSplitter.java:50) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:98) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78) ... 75 more
Look at the line 25 of MsgTypeSplitter
Code:at splitter.MsgTypeSplitter.splitMessage(MsgTypeSplitter.java:25)
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
it is:
Code:for (IData data : dataList) { ...Code:List<IData> dataList = ((Packet) message.getPayload()).getDataList();
@snc85
I am sorry but at this point it is clearly became a pure Java problem in user's code. I think we are all convinced that there is nothing in the framework that causes this problem.
The responses Artem and I had given you are aimed to help you (give you a hint) to locate the problem. But it is you who eventually have to find it and resolve it since only you have access to all the moving pieces. Sending short responses as you just did and expecting us to sit here trying to figure out what it all means without having any context does not help.
Think about forum ethics and consider that people here are doing it at their own free time and free will so if you want help then help us as well, by spending a little time trying to apply what you've learned from the previous reply before sending another question or meaningless reply as you just did.
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
Ok.thanks for Your free time.
@snc85
The reason of your problem is: when your read data in one thread, some other thread modifies your data...
I know that...but Splitter component should be thread-safe...am I wrong?
It is not problem of thread-safe Splitter.
The problem is in your collection of message's paylod.
Try this:
Code:final List<IData> dataList = new ArrayList<IData>(((Packet) message.getPayload()).getDataList());
As Artem pointed out, the issue has nothing to do with Splitter. You have a custom Array or List that is part of the Message payload or headers and that value is modified concurrently by more then one thread. And although Spring Integration does ensure Message immutability by creating a new Message for every exchange, we can not possibly control how many component in your code have access to the same reference of the object that is stored in the Message.
Just look at the following code
Messages are different but the payload they have is the same.Code:Foo foo = new Foo() Message msg1 = new GenericMessage<Foo>(foo); Message msg2 = new GenericMessage<Foo>(foo) boolean msgSame = msg1.equals(msg2) // will obviously be 'false' boolean payloadSame = msg1.getPayload().equals(msg2.getPayload()) // will obviously be 'true'
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/