IntelliJ IDEA didn't report ConcurrentModificationException while it occurred

70 views Asked by At

I met with a problem that, when I use for-iterator, I changed the list(ArrayList) to which the iterator belongs:

for (Term term : terms) {
    for (int j = 0; j < expr2.getTerms().size(); j++) {
        res.add(term.mulTerm(expr2.getTerms().get(j)));
    }
}

But the IntelliJ IDEA didn't give any signals and run as normal, it just shew:

Process finished with exit code 0

But when I used single-step debugging in IntelliJ IDEA, and it could be seen that the program executed the codes below:

final void checkForComodification() {
    if (modCount != expectedModCount)
        throw new ConcurrentModificationException();
}

And finally the program stopped and returned as normal while it had thrown ConcurrentModificationException. I'm wondering why this phenomenon occurred, thank you!

0

There are 0 answers