ConcurrentModificationException without modifications?

A

Andrea Hahn

Hello,

I keep getting a "ConcurrentModificationException" which turns up
sporadically. In contrast to what I could find on that in the internet I
could swear that the "resultList" and the iterator are not being modifed
from anywhere else when the code shown below is executed. While the two
"System.out.println" in the snippet correctly give the values true for
hasNext() and (e.g.) 8 for size(), setting a watch expression and stepping
up to the while-statement with JBuilder shows me the values false and 0 for
these expressions at the same time. I guess this is a stupid beginner's
mistake, but I would really appreciate your help!

Andrea

[public java.util.List getIntermediate() of object rsi returns a list of
Response objects for which some "nice" output is to be provided.]
_________________________________

List resultList = rsi.getIntermediate();

Iterator i = resultList.iterator();
System.out.println(i.hasNext());
System.out.println(resultList.size());
while (i.hasNext()) {
//the next line (sporadically!) provokes a
ConcurrentModificationException:
Response oneResponse = (Response) i.next();
oneResponse.niceResponse2Screen();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top