Skip to content
Snippets Groups Projects
Unverified Commit 81dd57ff authored by Matthias Urhahn's avatar Matthias Urhahn Committed by GitHub
Browse files

Fix passive config requests triggering a refresh (EXPOSUREAPP-3774) (#1608)


* Make config sharing behavior `SharingStarted.Lazily`. (start once, never release)
Otherwise classes that are just interested in the current config, if there is no other subscriber active,
would launch the `startValueProvider` and pull a config each time.

The ExposureDetectionTracker is such a candidate that would like to use the latest config every ~3min.

While this already no longer happens since "Track config changes" (4d1ecb54),
because there is no a class that is permanently subscribed to `currentConfig`, we should not rely on side-effects,
so let's make the sharing behavior explicit.

* Fix test regression.

Co-authored-by: default avatarharambasicluka <64483219+harambasicluka@users.noreply.github.com>
parent 73b9fbe3
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ class AppConfigProvider @Inject constructor( ...@@ -22,7 +22,7 @@ class AppConfigProvider @Inject constructor(
loggingTag = "AppConfigProvider", loggingTag = "AppConfigProvider",
scope = scope, scope = scope,
coroutineContext = dispatcherProvider.IO, coroutineContext = dispatcherProvider.IO,
sharingBehavior = SharingStarted.WhileSubscribed(replayExpirationMillis = 0) sharingBehavior = SharingStarted.Lazily
) { ) {
source.retrieveConfig() source.retrieveConfig()
} }
......
...@@ -98,7 +98,7 @@ class AppConfigProviderTest : BaseIOTest() { ...@@ -98,7 +98,7 @@ class AppConfigProviderTest : BaseIOTest() {
} }
@Test @Test
fun `appConfig uses WHILE_SUBSCRIBED mode`() = runBlockingTest2(ignoreActive = true) { fun `appConfig uses LAZILY mode`() = runBlockingTest2(ignoreActive = true) {
val instance = createInstance(this) val instance = createInstance(this)
val testCollector1 = instance.currentConfig.test(startOnScope = this) val testCollector1 = instance.currentConfig.test(startOnScope = this)
...@@ -123,7 +123,7 @@ class AppConfigProviderTest : BaseIOTest() { ...@@ -123,7 +123,7 @@ class AppConfigProviderTest : BaseIOTest() {
advanceUntilIdle() advanceUntilIdle()
testCollector4.cancel() testCollector4.cancel()
coVerify(exactly = 2) { source.retrieveConfig() } coVerify(exactly = 1) { source.retrieveConfig() }
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment