Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-879

maven-surefire-report-plugin fails some times with ConcurrentModificationException when running parallel TestNG

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.12
    • Fix Version/s: 2.12.1
    • Component/s: TestNG support
    • Labels:
      None
    • Environment:
      Java version: 1.6.0_32
      Maven version: 3.0.4
      maven-surefire-report-plugin: 2.12
      TestNG: 5.14.10

      Description

      I'm running TestNG tests in parallel and get this exception ConcurrentModificationException.

      My quick analysis is that at the end of the test the method TestSetRunListener.getAsString is accessing the list of captured output while another thread (a stray thread spawned by the test or a completely different concurrent test) generates some more console output causing an append to the list which results in ConcurrentModificationException.

      To fix this we need to ensure getAsString accesses the list atomically. A possible solution is to copy/clone the list before iterating over it.

      Here is the stakctrace I get.

      java.util.ConcurrentModificationException
      at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
      at java.util.AbstractList$Itr.next(AbstractList.java:343)
      at org.apache.maven.plugin.surefire.report.TestSetRunListener.getAsString(TestSetRunListener.java:209)
      at org.apache.maven.plugin.surefire.report.TestSetRunListener.testFailed(TestSetRunListener.java:168)
      at org.apache.maven.surefire.testng.TestNGReporter.onTestFailure(TestNGReporter.java:104)
      at org.testng.internal.Invoker.runTestListeners(Invoker.java:1796)
      at org.testng.internal.Invoker.runTestListeners(Invoker.java:1780)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:749)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
      at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
      at org.testng.TestRunner.privateRun(TestRunner.java:749)
      at org.testng.TestRunner.run(TestRunner.java:600)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
      at org.testng.SuiteRunner.access$000(SuiteRunner.java:34)
      at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:351)
      at org.testng.internal.thread.ThreadUtil$CountDownLatchedRunnable.run(ThreadUtil.java:147)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)

        Attachments

        1. surefire-879-bug.zip
          2 kB
          Adrian Nistor

          Activity

            People

            • Assignee:
              pgier Paul Gier
              Reporter:
              anistor Adrian Nistor
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: