title: Mule ESB - ConcurrentModificationException in FileMessageReceiver
body: <p>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.</p>
  
  <p>I am seeing this exception in the log:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>The exception is thrown here: <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#199" rel="nofollow">http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#199</a></p>
  
  <p>I've noticed that in this case <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#675" rel="nofollow">http://grepcode.com/file/repo1.maven.org/maven2/org.mule.transports/mule-transport-file/3.5.0/org/mule/transport/file/FileMessageReceiver.java#675</a> the same collection object is returned every time files.isEmpty() - this is not ideal and could very well be the cause of the problem.</p>
  
  <p>Now, luckily this exception is not disruptive overall, except it probably makes it skip a poll cycle and pollutes the log.</p>
  
  <p>Anyone seen this before / ideas?</p>