Skip to content

Commit

Permalink
fix(provider): attempt to fix ConcurrentModificationException on up…
Browse files Browse the repository at this point in the history
…dater

Former-commit-id: ab5187c
  • Loading branch information
rhenwinch committed Nov 8, 2024
1 parent b132517 commit 12c9cc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.flixclusive.provider.Provider
import com.flixclusive.provider.settings.ProviderSettings
import dagger.hilt.android.qualifiers.ApplicationContext
import dalvik.system.PathClassLoader
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
Expand Down Expand Up @@ -58,6 +59,7 @@ class ProviderManager @Inject constructor(
private val classLoaders: MutableMap<PathClassLoader, Provider> = Collections.synchronizedMap(HashMap())

private var notificationChannelHasBeenInitialized = false
val initialization = CompletableDeferred<Unit>()

/**
* An observable map of provider data
Expand Down Expand Up @@ -117,6 +119,8 @@ class ProviderManager @Inject constructor(

notificationChannelHasBeenInitialized = true
}

initialization.complete(Unit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class ProviderUpdaterUseCase @Inject constructor(
private var notificationChannelHasBeenInitialized = false

suspend fun checkForUpdates(notify: Boolean) {
// Wait for providers to be initialized
// To avoid ConcurrentModificationException
providerManager.initialization.await()

val appSettingsProvider = appSettingsManager.providerSettings.data.first()

outdatedProviders.clear()
Expand Down

0 comments on commit 12c9cc0

Please sign in to comment.