mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
fixing concurrent dispatch crash by using copy on write set
- whilst closing the session, we iterate through all the listeners calling onSessionStopped however some implementations also use this callback to remove themselves from the listeners, causing the concurrent modification crash
This commit is contained in:
parent
a8cd6ca497
commit
23cd6dae42
1
changelog.d/5821.bugfix
Normal file
1
changelog.d/5821.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fixes concurrent modification crash when signing out or launching the app
|
@ -19,12 +19,13 @@ package org.matrix.android.sdk.internal.session
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.CopyOnWriteArraySet
|
||||
import javax.inject.Inject
|
||||
|
||||
@SessionScope
|
||||
internal class SessionListeners @Inject constructor() {
|
||||
|
||||
private val listeners = mutableSetOf<Session.Listener>()
|
||||
private val listeners = CopyOnWriteArraySet<Session.Listener>()
|
||||
|
||||
fun addListener(listener: Session.Listener) {
|
||||
synchronized(listeners) {
|
||||
|
Loading…
Reference in New Issue
Block a user