Adjusted subscription cleanup to avoid mutating the watcher map while iterating it, preventing the ConcurrentModificationException when accounts switch

This commit is contained in:
davotoula
2025-11-05 18:52:40 +01:00
parent 178582f3c4
commit c07202944d

View File

@@ -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>()