Community
Participate
Working Groups
The following code shows a fix to a potential problem of the removeAll implementation in DelegatingEList: public boolean removeAll(Collection collection) { boolean modified = false; for (ListIterator i = delegateListIterator(); i.hasNext(); ) { if (collection.contains(i.next())) { //remove(i.previousIndex()); -- this caused the exception!!! i.remove(); // this fixed the exception in our case modified = true; } } return modified; } The current code (the documented out line of this code snippet) does call a remove on the list which leads to a concurrent modificatioon exception. I think the iterator remove should be called and in our scenario the exception disappeared.
Ronald, Thanks for reporting this. I've command the fix to change the code to this: public boolean removeAll(Collection collection) { boolean modified = false; for (ListIterator i = listIterator(); i.hasNext(); ) { if (collection.contains(i.next())) { i.remove(); modified = true; } } return modified; } I.e., what you suggested, but I've also changed the iterator being used to ensure that the overriden remove(int) method is called when remove() is called on the iterator. The retainAll methods has the same problem and is similarly fixed.
[contrib email="mail@ronald-steinhau.de"/]
Fixed in 2.2.0 I200603090000
Move to verified as per bug 206558.
Add iplog flag to whole bug as there's no attachment here.