Note bulk methods in Javadocs for Collections.synchronizedXxx()
martinrb at google.com
Sat Dec 28 13:23:21 UTC 2019
In general you are right, but ...
IIRC I once modified ArrayList(Collection) and Vector(Collection) but not
HashSet(Collection) to avoid iterators due to this problem.
And Collections.synchronizedXxx cannot know how other software makes use of
On Sat, Dec 28, 2019 at 1:50 AM Roman Leventov <leventov.ru at gmail.com>
> I think Javadocs for Collections.synchronizedXxx() should mention not
> only "traversing it via Iterator, Spliterator or Stream" as something that
> must be synchronized externally, but also cases when a synchronized
> collection is an argument to a bulk collection method, including:
> - new ArrayList(syncList), new HashSet(syncSet), etc.
> - List.copyOf(syncList)
> - otherColl.addAll(syncList), otherColl.removeAll(syncList),
> Though this is logically inferable, this is far from being obvious and
More information about the core-libs-dev