From 594b442a213daf2b01369ab3a1bc8d36bba35c78 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 12 Apr 2022 17:26:15 +0100 Subject: [PATCH] copying the list of new session listeners to avoid concurrent modification - copying the list avoids the need to synchronise the add/removing/iterations --- changelog.d/5746.bugfix | 1 + .../matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/5746.bugfix diff --git a/changelog.d/5746.bugfix b/changelog.d/5746.bugfix new file mode 100644 index 0000000000..975a75f70a --- /dev/null +++ b/changelog.d/5746.bugfix @@ -0,0 +1 @@ +Fixes crash when navigating the app whilst processing new room keys \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt index 89fb43ef2e..c256911bd2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt @@ -74,7 +74,7 @@ internal class RoomDecryptorProvider @Inject constructor( this.newSessionListener = object : NewSessionListener { override fun onNewSession(roomId: String?, senderKey: String, sessionId: String) { // PR reviewer: the parameter has been renamed so is now in conflict with the parameter of getOrCreateRoomDecryptor - newSessionListeners.forEach { + newSessionListeners.toList().forEach { try { it.onNewSession(roomId, senderKey, sessionId) } catch (e: Throwable) {