Created by: navkast
For TestNG, a @Test
method can run concurrently using a @DataProvider
:
@DataProvider(name = "testList", parallel = true)
This causes an exception in Buck as follows:
java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042)
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996)
at com.facebook.buck.testrunner.BaseRunner.writeResult(BaseRunner.java:100)
at com.facebook.buck.testrunner.TestNGRunner.run(TestNGRunner.java:96)
at com.facebook.buck.testrunner.BaseRunner.runAndExit(BaseRunner.java:301)
at com.facebook.buck.testrunner.TestNGMain.main(TestNGMain.java:48)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.facebook.buck.jvm.java.runner.FileClassPathRunner.main(FileClassPathRunner.java:88)
The fix is to simply move the test runner's collection of test results to be a concurrency-safe collection. I use ConcurrentLinkedQueue
: this should be faster than explicit synchronized blocks or using Collections.synchronizedList()
.