refactor: Improve data repository lifecycle safety - #194
Merged
ProdigyV21 merged 2 commits intoMay 15, 2026
Merged
Conversation
Refactored DataStore keys into a companion object in PlaybackTelemetryRepository. Modernized list generation in AddonRuntimeAggregator to avoid mutable list allocation. Fixed concurrency flaw in CloudSyncCoordinator by replacing @volatile with AtomicBoolean.
Himanth-reddy
deleted the
chore/auto-refactor-2026-05-15-13087954862751201397
branch
July 23, 2026 10:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original PR #11 Context
Source PR: Himanth-reddy#11
CodeRabbit walkthrough from PR #11:
Original Changes
app/src/main/kotlin/com/arflix/tv/data/repository/AddonRuntimeAggregator.ktresolveMovieStreamsandresolveEpisodeStreamsnow use early returns on empty input and direct STREMIO runtime resolution with.orEmpty(), removing intermediate mutable lists and conditional blocks.app/src/main/kotlin/com/arflix/tv/data/repository/CloudSyncCoordinator.ktstartedstate changed from volatile boolean toAtomicBoolean, withstart()using atomiccompareAndSet(false, true)for idempotent behavior andstop()resetting viaset(false).app/src/main/kotlin/com/arflix/tv/data/repository/PlaybackTelemetryRepository.ktstartupSamplesKey,startupAvgMsKey, and telemetry counters) moved from instance-level properties into aprivate companion object.Review Feedback Addressed
CodeRabbit flagged a remaining lifecycle race in
CloudSyncCoordinator.kt:AtomicBoolean.compareAndSetserialized concurrentstart()calls, but did not protectcollectorJobandflushJobfrom a concurrentstop()call. That could allowstart()to assign a live job afterstop()had nulled the job fields, leaving coroutine work running whilestarted == false.CodeRabbit also suggested replacing the fully-qualified
java.util.concurrent.atomic.AtomicBooleanusage with an import.Additional Commit Added
Commit:
c7d0944 fix: synchronize cloud sync coordinator lifecycleThis commit:
lifecycleLockinCloudSyncCoordinator.start()andstop()sostarted,collectorJob, andflushJobare updated together.scheduleFlush()and skips scheduling if the coordinator has already stopped.flushJobunder the same lifecycle lock.AtomicBooleandirectly and usesAtomicBoolean(false).Validation
./gradlew assembleSideloadDebug --no-daemon