Run-listener throwing exception causes this, and it can be seen that removing an element by its iterator is not suppored on copyonwritearraylist.
Caused by: java.lang.IllegalStateException
at java.util.AbstractList$Itr.remove(AbstractList.java:356)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:43)
at org.junit.runner.notification.RunNotifier.fireTestRunFinished(RunNotifier.java:68)
at org.junit.runner.JUnitCore.run(JUnitCore.java:158)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.junit.runner.JUnitCore.run(JUnitCore.java:127)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:51)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:110)
Fix with the following change or similar:
for (Iterator all = fListeners.iterator(); all.hasNext();){
RunListener next = all.next();
try {
notifyListener(next);
} catch (Exception e) {
fListeners.remove( next); // Remove the offending listener first to avoid an infinite loop
fireTestFailure(new Failure(Description.TEST_MECHANISM, e));
}
}
Run-listener throwing exception causes this, and it can be seen that removing an element by its iterator is not suppored on copyonwritearraylist.
Caused by: java.lang.IllegalStateException at java.util.AbstractList$Itr.remove(AbstractList.java:356) at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:43) at org.junit.runner.notification.RunNotifier.fireTestRunFinished(RunNotifier.java:68) at org.junit.runner.JUnitCore.run(JUnitCore.java:158) at org.junit.runner.JUnitCore.run(JUnitCore.java:136) at org.junit.runner.JUnitCore.run(JUnitCore.java:127) at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:51) at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:110)
Fix with the following change or similar: for (Iterator all = fListeners.iterator(); all.hasNext();){
RunListener next = all.next();
try {
notifyListener(next);
} catch (Exception e) {
fListeners.remove( next); // Remove the offending listener first to avoid an infinite loop
fireTestFailure(new Failure(Description.TEST_MECHANISM, e));
}
}