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