[concurrency-interest] Race condition in CopyOnWriteArrayList.equals Bug 6318638

Jason Mehrens jason_mehrens at hotmail.com
Fri Sep 23 14:38:35 EDT 2005


Won't this bug still carry over to the CopyOnWriteArraySet?  The 
CopyOnWriteArraySet uses the AbstractSet implementation of the of equals 
which calls also calls size and containsAll which could view two different 
snapshots.

Do collections have to make any guarantees on the behavior of input 
Collections being passed into bulk operation methods like equals, 
containsAll, removeAll, etc.?

For example, if a program calls equals on COWArrayList and the parameter is 
another COWArrayList, Vector, synchonizedList() the same type of race still 
exists between size() and ListIterator() on the input Collection (check the 
source code of COWArrayList.equals 1.56). If the input Collection size is 
reduced before or during the traversal of the ListIterator a 
NoSuchElementException or ConcurrentModificationException is thrown from 
equals.
As a user of the API I would consider the ConcurrentModifcationException my 
problem (misuse) but the NoSuchElementException I would consider something 
the COWArrayList would have to hide or prevent.

Regards,

Jason Mehrens




More information about the Concurrency-interest mailing list