mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 13:57:10 +01:00
Adjusted subscription cleanup to avoid mutating the watcher map while iterating it, preventing the ConcurrentModificationException when accounts switch
This commit is contained in:
@@ -186,11 +186,11 @@ class AccountFollowsLoaderSubAssembler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// removes accounts that are not being subscribed anymore.
|
// removes accounts that are not being subscribed anymore.
|
||||||
accountUpdatesJobMap.forEach {
|
// Cancel watchers for accounts no longer observed using a snapshot to avoid CME
|
||||||
if (it.key !in uniqueSubscribedAccounts.keys) {
|
accountUpdatesJobMap.keys
|
||||||
endWatcher(it.key)
|
.toList()
|
||||||
}
|
.filter { it !in uniqueSubscribedAccounts.keys }
|
||||||
}
|
.forEach { endWatcher(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private val accountUpdatesJobMap = mutableMapOf<User, Job>()
|
private val accountUpdatesJobMap = mutableMapOf<User, Job>()
|
||||||
|
|||||||
Reference in New Issue
Block a user