You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This usage is hidden because old package level methods are used dating back to kotlin native's old memory model, but a concurrent list of the observers is iterated through which is unsafe, as any modification while iterating will cause a crash. forEach usage should always be wrapped in synchronized.
This does raise the question if ConcurrentList should even conform to the List interface, it would be better to expose the List only from inside synchronized (as it already does).
val l =ConcurrentMutableList()
// current l is a `List` so you can do this:
l.forEach { /* crashes when the list is changed from the outside*/ }
l.synchronized {
forEach { } // already possible and safe.
}
Maybe a ConcurrentList interface should be considered that does not allow mutation, which can be created with a toConcurrentList()/asConcurrentList on a ConcurrentMutableList
The text was updated successfully, but these errors were encountered:
This usage is hidden because old package level methods are used dating back to kotlin native's old memory model, but a concurrent list of the observers is iterated through which is unsafe, as any modification while iterating will cause a crash. forEach usage should always be wrapped in
synchronized
.This does raise the question if
ConcurrentList
should even conform to theList
interface, it would be better to expose theList
only from inside synchronized (as it already does).Maybe a
ConcurrentList
interface should be considered that does not allow mutation, which can be created with atoConcurrentList()
/asConcurrentList
on aConcurrentMutableList
The text was updated successfully, but these errors were encountered: