Skip to content

Commit ab5187c

Browse files
committed
fix(provider): attempt to fix ConcurrentModificationException on updater
1 parent 25151fd commit ab5187c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

data/provider/src/main/kotlin/com/flixclusive/data/provider/ProviderManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import com.flixclusive.provider.Provider
3131
import com.flixclusive.provider.settings.ProviderSettings
3232
import dagger.hilt.android.qualifiers.ApplicationContext
3333
import dalvik.system.PathClassLoader
34+
import kotlinx.coroutines.CompletableDeferred
3435
import kotlinx.coroutines.flow.first
3536
import kotlinx.coroutines.launch
3637
import okhttp3.OkHttpClient
@@ -58,6 +59,7 @@ class ProviderManager @Inject constructor(
5859
private val classLoaders: MutableMap<PathClassLoader, Provider> = Collections.synchronizedMap(HashMap())
5960

6061
private var notificationChannelHasBeenInitialized = false
62+
val initialization = CompletableDeferred<Unit>()
6163

6264
/**
6365
* An observable map of provider data
@@ -117,6 +119,8 @@ class ProviderManager @Inject constructor(
117119

118120
notificationChannelHasBeenInitialized = true
119121
}
122+
123+
initialization.complete(Unit)
120124
}
121125
}
122126

domain/updater/src/main/kotlin/com/flixclusive/domain/updater/ProviderUpdaterUseCase.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class ProviderUpdaterUseCase @Inject constructor(
4343
private var notificationChannelHasBeenInitialized = false
4444

4545
suspend fun checkForUpdates(notify: Boolean) {
46+
// Wait for providers to be initialized
47+
// To avoid ConcurrentModificationException
48+
providerManager.initialization.await()
49+
4650
val appSettingsProvider = appSettingsManager.providerSettings.data.first()
4751

4852
outdatedProviders.clear()

0 commit comments

Comments
 (0)