-
Notifications
You must be signed in to change notification settings - Fork 496
Improve HotDataFlow behavior (EXPOSUREAPP-3777) #1612
Conversation
d4rken
commented
Nov 16, 2020
- Prevent re-execution of past submissions when the observable goes cold.
- Guard internal value updates with a mutex in case the value update is not as thread-safe as we think it is.
* Prevent re-execution of past submissions when the observable goes cold. * Guard internal value updates with a mutex in case the value update is not as thread-safe as we think it is.
Timber.tag(tag).v("updateActions resetReplayCache().") | ||
updateActions.resetReplayCache() | ||
} | ||
.collect { updateAction -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suspicious that our access of currentValue
in .collect { }
was not thread-safe, which is why I added the mutex.
updateActions | ||
.onCompletion { | ||
Timber.tag(tag).v("updateActions resetReplayCache().") | ||
updateActions.resetReplayCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we unsubscribe, and the HotDataFlow
goes cold, and then resubscribe, we would replay all previous update actions on the new value.
I don't think this affected the current issue, but it's a bug nonetheless. We should reset the cache here to prevent the actions from being replayed.
Corona-Warn-App/src/test/java/de/rki/coronawarnapp/util/flow/HotDataFlowTest.kt
Outdated
Show resolved
Hide resolved
66de9d1
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm. Test are running fine now.