Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-544

ConcurrentModificationException in MdcInjectionFilter

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-M1
    • 2.0.0-M2
    • Core
    • None

    Description

      When doing some load testing on FtpServer, I ran into a threading
      issue in MdcInjectionFilter. When adding some load, I frequently get a
      ConcurrentModificationException on removing the MDC properties. Here's
      the stacktrace:

      java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
      at java.util.HashMap$KeyIterator.next(HashMap.java:828)
      at org.apache.mina.filter.logging.MdcInjectionFilter.filter(MdcInjectionFilter.java:140)
      at org.apache.mina.filter.util.CommonEventFilter.messageReceived(CommonEventFilter.java:67)
      at org.apache.mina.common.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:401)
      at org.apache.mina.common.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:38)
      at org.apache.mina.common.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:820)
      at org.apache.mina.common.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:604)
      at org.apache.mina.common.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:401)
      at org.apache.mina.common.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:395)
      at org.apache.mina.common.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:425)
      at org.apache.mina.common.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:387)
      at org.apache.mina.common.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:379)
      at org.apache.mina.common.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:43)
      at org.apache.mina.common.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:676)
      at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:619)

      The cause of the problem is a call to setProperty() from
      org.apache.ftpserver.command.USER. I'm not familiar enough with the
      MDC filter to identify the culprit. Simply synchronizing the context
      Map does not help. The test I'm running is quite simple:

      package org.apache.ftpserver.clienttests;

      public class MdcThreadingTest extends ClientTestTemplate {

      public void testLoginMulti() throws Exception {
      tearDown();
      for(int i = 0; i<10000; i++)

      { setUp(); assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD)); tearDown(); }

      System.out.println("All done!");
      }
      }

      Attachments

        Activity

          use ConcurrentHashMap instead of HashMap

          mbosteels Maarten Bosteels added a comment - use ConcurrentHashMap instead of HashMap

          People

            mbosteels Maarten Bosteels
            mbosteels Maarten Bosteels
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: