Skip to content

Conversation

@akarnokd
Copy link
Member

@akarnokd akarnokd commented Jan 4, 2019

This PR fixes a race condition in the ObservableRepeatWhen operator for the case when the repeat signal is not 1-for-1 and a new subscription may race with the clearing of the previous disposable because active is set to false too early. The fix is to swap the two operations.

Observable.retryWhen and the Flowable versions do not have this bug. Unit tests were added to all 4 operators to verify the correct behavior regardless.

Fixes: #6358

@akarnokd akarnokd added this to the 2.2 backlog milestone Jan 4, 2019
@codecov
Copy link

codecov bot commented Jan 4, 2019

Codecov Report

Merging #6359 into 2.x will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6359      +/-   ##
============================================
+ Coverage     98.24%   98.26%   +0.01%     
- Complexity     6281     6283       +2     
============================================
  Files           672      672              
  Lines         44990    44990              
  Branches       6223     6223              
============================================
+ Hits          44202    44210       +8     
+ Misses          247      241       -6     
+ Partials        541      539       -2
Impacted Files Coverage Δ Complexity Δ
...nal/operators/observable/ObservableRepeatWhen.java 100% <100%> (+1.56%) 2 <0> (ø) ⬇️
...tivex/internal/schedulers/TrampolineScheduler.java 96.1% <0%> (-2.6%) 6% <0%> (ø)
...va/io/reactivex/internal/queue/SpscArrayQueue.java 97.61% <0%> (-2.39%) 22% <0%> (-1%)
...perators/mixed/ObservableConcatMapCompletable.java 97.74% <0%> (-2.26%) 3% <0%> (ø)
...rnal/operators/flowable/FlowableSkipLastTimed.java 95.91% <0%> (-2.05%) 2% <0%> (ø)
...nternal/operators/observable/ObservableWindow.java 98% <0%> (-2%) 3% <0%> (ø)
...activex/internal/schedulers/ScheduledRunnable.java 98.07% <0%> (-1.93%) 29% <0%> (-1%)
...x/internal/operators/flowable/FlowablePublish.java 97.02% <0%> (-1.71%) 11% <0%> (ø)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
...l/operators/observable/ObservableFlatMapMaybe.java 93.46% <0%> (-1.31%) 2% <0%> (ø)
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e0c8b5...ea40336. Read the comment docs.

@eleventigers
Copy link

Nice! Thanks @akarnokd for such a quick fix, I have verified that it fixes #6358 locally.

@akarnokd akarnokd merged commit 090f99e into ReactiveX:2.x Jan 4, 2019
@akarnokd akarnokd deleted the DoubleDisposableSetFix branch January 4, 2019 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.x: Disposable already set! using delaySubscription with takeUntil/repeatWhen

3 participants