Skip to content

Commit

Permalink
Merge pull request #6469 from vector-im/feature/bma/fix_crash_on_Defa…
Browse files Browse the repository at this point in the history
…ultBackgroundDetectionObserver

Fix ConcurrentModificationException on BackgroundDetectionObserver
  • Loading branch information
ouchadam authored Jul 7, 2022
2 parents 09f158e + b68e01c commit 4126e64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/6469.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ConcurrentModificationException on BackgroundDetectionObserver
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.util
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import timber.log.Timber
import java.util.concurrent.CopyOnWriteArraySet

internal interface BackgroundDetectionObserver : DefaultLifecycleObserver {
val isInBackground: Boolean
Expand All @@ -37,7 +38,7 @@ internal class DefaultBackgroundDetectionObserver : BackgroundDetectionObserver
override var isInBackground: Boolean = true
private set

private val listeners = LinkedHashSet<BackgroundDetectionObserver.Listener>()
private val listeners = CopyOnWriteArraySet<BackgroundDetectionObserver.Listener>()

override fun register(listener: BackgroundDetectionObserver.Listener) {
listeners.add(listener)
Expand Down

0 comments on commit 4126e64

Please sign in to comment.