From 320befcf36156b57c99ead03161abe4bf360b4fb Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Sat, 7 Oct 2023 00:36:55 +0200 Subject: [PATCH] Fix potential concurrency issue Made the registeredPlugins list CoW since there are multiple threads iterating and modifying it, potentially at the same time. --- src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.kt b/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.kt index d5e102e8..d8c721d4 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.kt +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/AlbumArtCache.kt @@ -28,6 +28,7 @@ import java.net.MalformedURLException import java.net.URL import java.net.URLDecoder import java.security.MessageDigest +import java.util.concurrent.CopyOnWriteArrayList /** * Handles the cache for album art @@ -67,7 +68,7 @@ internal object AlbumArtCache { /** * A list of plugins to notify on fetched album art */ - private val registeredPlugins = ArrayList() + private val registeredPlugins = CopyOnWriteArrayList() /** * Initializes the disk cache. Needs to be called at least once before trying to use the cache