Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Removing through iterator not supported by CopyOnWriteArrayList #209

Closed
krosenvold opened this Issue · 2 comments

3 participants

@krosenvold

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));
}
}

@dsaff
Owner

Nice bug catch. Thanks!

@Stephan202

For reference: there are other issues with this code, please see #395.

@dsaff dsaff closed this in 3639784
@jherault jherault referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.