Skip to content

Commit 0f23b90

Browse files
committed
Iterate local list to avoid concurrent modification
1 parent 709b441 commit 0f23b90

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
@@ -45,10 +45,9 @@ open class EventProducer<THandler> : IEventNotifier<THandler> {
4545
* @param callback The callback will be invoked for each subscribed handler, allowing you to call the handler.
4646
*/
4747
fun fire(callback: (THandler) -> Unit) {
48-
synchronized(subscribers) {
49-
for (s in subscribers) {
50-
callback(s)
51-
}
48+
val localList = subscribers.toList()
49+
for (s in localList) {
50+
callback(s)
5251
}
5352
}
5453

0 commit comments

Comments
 (0)