diff --git a/src/main/java/rx/internal/operators/OnSubscribeRange.java b/src/main/java/rx/internal/operators/OnSubscribeRange.java index f648e6f414..bcfbe0736b 100644 --- a/src/main/java/rx/internal/operators/OnSubscribeRange.java +++ b/src/main/java/rx/internal/operators/OnSubscribeRange.java @@ -55,12 +55,11 @@ private RangeProducer(Subscriber 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()) {