Bug in ArrayList iterator
sbaiduzh at redhat.com
Wed Jan 7 11:38:03 UTC 2015
On Wednesday 07 January 2015 12:29:44 Mario Torre wrote:
> > Yes, but that exactly how it works now, that's why second invocation of
> > hasNext() returns false and we can see the issue Remi is talking about. If
> > hasNext() will be throwing ConcurrentModification than will work as early
> > warning system that something is wrong with this iterator.
> But hasNext isn't modifying things, why should it throw
> ConcurrentModification? I would find it very confusing, and also
> likely non backward compatible.
Yes. More than that, guide page says directly that you should not use for-each
for filtering . Which means that what Remi has reported is not an issue,
just incorrectly applied for-each iterator, and probably the least effective
way to filter out the list. But as discussion went on with this in search of
solution - I still cannot see any other way to fix it than throw
ConcurrentModification from hasNext().
More information about the core-libs-dev