java.util.ConcurrentModificationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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.
    via by Victor Romero,
  • 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.
    via by Victor Romero,
    • 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)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,