Race condition in CopyOnWriteArrayList.equals Bug 6318638

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Race condition in CopyOnWriteArrayList.equals Bug 6318638

Jason Mehrens
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


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest