Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: DefaultSplitter and java.util.ConcurrentModificationException

  1. #11
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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.

  2. #12
    Join Date
    May 2011
    Location
    Cracow, Poland
    Posts
    53

    Default

    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

  3. #13
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Look at the line 25 of MsgTypeSplitter
    Code:
    at splitter.MsgTypeSplitter.splitMessage(MsgTypeSplitter.java:25)

  4. #14
    Join Date
    May 2011
    Location
    Cracow, Poland
    Posts
    53

    Default

    it is:
    Code:
    for (IData data : dataList) {
    ...
    Code:
    List<IData> dataList = ((Packet) message.getPayload()).getDataList();

  5. #15
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    @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.

  6. #16
    Join Date
    May 2011
    Location
    Cracow, Poland
    Posts
    53

    Default

    Ok.thanks for Your free time.

  7. #17
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    646

    Default

    @snc85
    The reason of your problem is: when your read data in one thread, some other thread modifies your data...

  8. #18
    Join Date
    May 2011
    Location
    Cracow, Poland
    Posts
    53

    Default

    I know that...but Splitter component should be thread-safe...am I wrong?

  9. #19
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    646

    Default

    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());

  10. #20
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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

    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'
    Messages are different but the payload they have is the same.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •