Skip to content

Commit

Permalink
Merge pull request #1796 from OneSignal/fix/event_producer_crash
Browse files Browse the repository at this point in the history
[5.0.0] Make subscribers in EventProducer synchronized
  • Loading branch information
emawby authored and jinliu9508 committed Feb 6, 2024
2 parents 0d10478 + 8b630e8 commit a741b1a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.onesignal.common.events
import com.onesignal.common.threading.suspendifyOnMain
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.*

/**
* A standard implementation that implements [IEventNotifier] and additional functionality to make
Expand All @@ -13,7 +14,7 @@ open class EventProducer<THandler> : IEventNotifier<THandler> {
override val hasSubscribers: Boolean
get() = _subscribers.any()

private val _subscribers: MutableList<THandler> = mutableListOf()
private val _subscribers: MutableList<THandler> = Collections.synchronizedList(mutableListOf())

override fun subscribe(handler: THandler) {
_subscribers.add(handler)
Expand Down

0 comments on commit a741b1a

Please sign in to comment.