Skip to content

Commit

Permalink
Merge pull request #2892 from davidmoten/range-race
Browse files Browse the repository at this point in the history
Fix Observable.range race condition
  • Loading branch information
akarnokd committed Apr 20, 2015
2 parents cbf8edf + f8f4cd0 commit aefdebb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/rx/internal/operators/OnSubscribeRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ private RangeProducer(Subscriber<? super Integer> o, int start, int end) {

@Override
public void request(long n) {
if (REQUESTED_UPDATER.get(this) == Long.MAX_VALUE) {
if (requested == Long.MAX_VALUE) {
// already started with fast-path
return;
}
if (n == Long.MAX_VALUE) {
REQUESTED_UPDATER.set(this, n);
if (n == Long.MAX_VALUE && REQUESTED_UPDATER.compareAndSet(this, 0, Long.MAX_VALUE)) {
// fast-path without backpressure
for (long i = index; i <= end; i++) {
if (o.isUnsubscribed()) {
Expand Down

0 comments on commit aefdebb

Please sign in to comment.