ConcurrentModificationException when running tests in parallel

467 views
Skip to first unread message

Michael May

unread,
Mar 13, 2015, 3:11:55 PM3/13/15
to testng...@googlegroups.com


java.util.ConcurrentModificationException

java.util.Hashtable$Enumerator.next(Hashtable.java:1367)
org.testng.internal.Invoker.classConfigurationFailed(Invoker.java:430)
org.testng.internal.Invoker.confInvocationPassed(Invoker.java:455)
org.testng.internal.Invoker.invokeMethod(Invoker.java:676)
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:882)
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1189)
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

I'm getting a ConcurrentModificationException every once an a while when running the test suite. Is there anyway I could prevent this? I have about 17k tests in the suite. At most one or two tests fail with this during a run, so it doesn't happen that often.

Michael May

unread,
Mar 15, 2015, 11:41:45 PM3/15/15
to testng...@googlegroups.com
hmm.. This only occurs when I synchronize the Before/After methods. After I made the blocks non-synchronized I no longer got the ConcurrentModificationException.

Cédric Beust ♔

unread,
Mar 16, 2015, 12:50:59 AM3/16/15
to testng...@googlegroups.com
Definitely a bug in TestNG but I haven't had the time to look in details.

-- 
Cédric


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Krishnan Mahadevan

unread,
Mar 16, 2015, 4:51:14 AM3/16/15
to testng...@googlegroups.com
Michael,
Do you think you could help provide a simple test which could recreate this problem ? I can try to fix this, if there is a test that re-produces the problem.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

Cédric Beust ♔

unread,
Mar 16, 2015, 4:50:38 PM3/16/15
to testng...@googlegroups.com

Also, note that ConcurrentModificationException is usually not a multithreading problem but caused by trying to iterate on a collection while an iteration is already happening (which can happen on a single thread). It doesn’t seem to be the case here, though, after a quick glance at the code (or I missed it).


-- 
Cédric

Michael May

unread,
Mar 17, 2015, 11:42:09 AM3/17/15
to testng...@googlegroups.com, ced...@beust.com
I'm not having that much luck on creating a test case that shows this. If I end up getting a test case together that shows this I'll post it here.
Reply all
Reply to author
Forward
0 new messages