java.util.ConcurrentModificationException

MuleSoft JIRA | Victor Romero | 2 years ago
  1. 0

    Mule ESB - ConcurrentModificationException in FileMessageReceiver

    Stack Overflow | 2 years ago | Guido N
    java.util.ConcurrentModificationException
  2. 0

    The following is an extract from http://stackoverflow.com/questions/27816447/mule-esb-concurrentmodificationexception-in-filemessagereceiver My Mule application deals with several different directories and it moves files around. I have a few file inbound endpoints and file connectors. I have situations where I have to poll different folders, process files, move them, poll again etc. I am seeing this exception in the log: java.util.ConcurrentModificationException at java.util.ArrayList.sort(ArrayList.java:1456) at java.util.Collections.sort(Collections.java:175) at org.mule.transport.file.FileMessageReceiver.poll(FileMessageReceiver.java:199) at org.mule.transport.AbstractPollingMessageReceiver.performPoll(AbstractPollingMessageReceiver.java:216) at org.mule.transport.PollingReceiverWorker.poll(PollingReceiverWorker.java:80) at org.mule.transport.PollingReceiverWorker.run(PollingReceiverWorker.java:49) at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267) at org.mule.work.WorkerContext.run(WorkerContext.java:286) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The exception is thrown here: http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#199 I've noticed that in this case http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#675 the same collection object is returned every time files.isEmpty() - this is not ideal and could very well be the cause of the problem. Now, luckily this exception is not disruptive overall, except it probably makes it skip a poll cycle and pollutes the log. It looks like the exception disappears if I change the listFiles() implementation when the list of files is empty. {code} package org.mule.transport.file; import org.mule.api.MuleException; import org.mule.api.construct.FlowConstruct; import org.mule.api.endpoint.InboundEndpoint; import org.mule.api.lifecycle.CreateException; import org.mule.api.transport.Connector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.util.ArrayList; import java.util.List; public class PatchedFileMessageReceiver extends FileMessageReceiver { private static final Logger log = LoggerFactory.getLogger(PatchedFileMessageReceiver.class); /** * * @param connector * @param flowConstruct * @param endpoint * @param readDir * @param moveDir * @param moveToPattern * @param frequency * @throws CreateException */ public PatchedFileMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint, String readDir, String moveDir, String moveToPattern, long frequency) throws CreateException { super(connector, flowConstruct, endpoint, readDir, moveDir, moveToPattern, frequency); } /** * * @return * @throws MuleException */ @Override List<File> listFiles() throws MuleException { List<File> list = super.listFiles(); if(list.isEmpty()) { log.trace("List of files is empty, I'm gonna return a new empty ArrayList"); } return ( list.isEmpty() ? new ArrayList<File>() : list ); } } {code} And then set the custom FileMessageReceiver on the file connector like this {code:xml} <file:connector name="source-file-connector" autoDelete="false" fileAge="1000" pollingFrequency="1000" > <service-overrides messageReceiver="org.mule.transport.file.PatchedFileMessageReceiver" /> </file:connector> {code} This stuff should be really fixed upstream. As a user one would expect not having to deal with this kind of problems.

    MuleSoft JIRA | 2 years ago | Victor Romero
    java.util.ConcurrentModificationException
  3. 0

    The following is an extract from http://stackoverflow.com/questions/27816447/mule-esb-concurrentmodificationexception-in-filemessagereceiver My Mule application deals with several different directories and it moves files around. I have a few file inbound endpoints and file connectors. I have situations where I have to poll different folders, process files, move them, poll again etc. I am seeing this exception in the log: java.util.ConcurrentModificationException at java.util.ArrayList.sort(ArrayList.java:1456) at java.util.Collections.sort(Collections.java:175) at org.mule.transport.file.FileMessageReceiver.poll(FileMessageReceiver.java:199) at org.mule.transport.AbstractPollingMessageReceiver.performPoll(AbstractPollingMessageReceiver.java:216) at org.mule.transport.PollingReceiverWorker.poll(PollingReceiverWorker.java:80) at org.mule.transport.PollingReceiverWorker.run(PollingReceiverWorker.java:49) at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267) at org.mule.work.WorkerContext.run(WorkerContext.java:286) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The exception is thrown here: http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#199 I've noticed that in this case http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#675 the same collection object is returned every time files.isEmpty() - this is not ideal and could very well be the cause of the problem. Now, luckily this exception is not disruptive overall, except it probably makes it skip a poll cycle and pollutes the log. It looks like the exception disappears if I change the listFiles() implementation when the list of files is empty. {code} package org.mule.transport.file; import org.mule.api.MuleException; import org.mule.api.construct.FlowConstruct; import org.mule.api.endpoint.InboundEndpoint; import org.mule.api.lifecycle.CreateException; import org.mule.api.transport.Connector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.util.ArrayList; import java.util.List; public class PatchedFileMessageReceiver extends FileMessageReceiver { private static final Logger log = LoggerFactory.getLogger(PatchedFileMessageReceiver.class); /** * * @param connector * @param flowConstruct * @param endpoint * @param readDir * @param moveDir * @param moveToPattern * @param frequency * @throws CreateException */ public PatchedFileMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint, String readDir, String moveDir, String moveToPattern, long frequency) throws CreateException { super(connector, flowConstruct, endpoint, readDir, moveDir, moveToPattern, frequency); } /** * * @return * @throws MuleException */ @Override List<File> listFiles() throws MuleException { List<File> list = super.listFiles(); if(list.isEmpty()) { log.trace("List of files is empty, I'm gonna return a new empty ArrayList"); } return ( list.isEmpty() ? new ArrayList<File>() : list ); } } {code} And then set the custom FileMessageReceiver on the file connector like this {code:xml} <file:connector name="source-file-connector" autoDelete="false" fileAge="1000" pollingFrequency="1000" > <service-overrides messageReceiver="org.mule.transport.file.PatchedFileMessageReceiver" /> </file:connector> {code} This stuff should be really fixed upstream. As a user one would expect not having to deal with this kind of problems.

    MuleSoft JIRA | 2 years ago | Victor Romero
    java.util.ConcurrentModificationException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Play 1.2.5 ConcurrentModification exceptions

    Stack Overflow | 1 year ago | user12384512
    play.exceptions.UnexpectedException: Unexpected Error
  6. 0

    Exception in router makes Wisdom a Zombie

    GitHub | 1 year ago | magnet
    java.util.ConcurrentModificationException

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.util.ConcurrentModificationException

      No message provided

      at java.util.ArrayList.sort()
    2. Java RT
      Collections.sort
      1. java.util.ArrayList.sort(ArrayList.java:1456)
      2. java.util.Collections.sort(Collections.java:175)
      2 frames
    3. org.mule.transport
      FileMessageReceiver.poll
      1. org.mule.transport.file.FileMessageReceiver.poll(FileMessageReceiver.java:199)
      1 frame
    4. Mule Core
      WorkerContext.run
      1. org.mule.transport.AbstractPollingMessageReceiver.performPoll(AbstractPollingMessageReceiver.java:216)
      2. org.mule.transport.PollingReceiverWorker.poll(PollingReceiverWorker.java:80)
      3. org.mule.transport.PollingReceiverWorker.run(PollingReceiverWorker.java:49)
      4. org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
      5. org.mule.work.WorkerContext.run(WorkerContext.java:286)
      5 frames
    5. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      3. java.lang.Thread.run(Thread.java:745)
      3 frames