Skip to content

Commit 8cdbab8

Browse files
committed
Iterate local list to avoid concurrent modification
1 parent 8aea849 commit 8cdbab8

File tree

1 file changed

+3
-4
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/events

1 file changed

+3
-4
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/events/EventProducer.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ open class EventProducer<THandler> : IEventNotifier<THandler> {
3939
* @param callback The callback will be invoked for each subscribed handler, allowing you to call the handler.
4040
*/
4141
fun fire(callback: (THandler) -> Unit) {
42-
synchronized(subscribers) {
43-
for (s in subscribers) {
44-
callback(s)
45-
}
42+
val localList = subscribers.toList()
43+
for (s in localList) {
44+
callback(s)
4645
}
4746
}
4847

0 commit comments

Comments
 (0)