-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1441)
at java.util.HashMap$KeyIterator.next(HashMap.java:1465)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1089)
at com.clover.nsd_stress.ZeroconfStressActivity.discover$lambda-5(ZeroconfStressActivity.kt:159)
I see the backing services field is a synchronized set, but according to the docs:
It is imperative that the user manually synchronize on the returned set when iterating over it.
However when the field is returned, it's wrapped in a Collections.unmodifiableCollection which just restricts write but not read operations on the wrapped collection. The caller has no idea they need to synchronize because they have no idea the result is a wrapped SynchronizedSet.
One option would be to have the getService() method synchronize on the source collection, making a copy, then return the copy. Or you could back it with a java.util.concurrent collection implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels