Skip to content

Commit e6708ca

Browse files
committed
mark one less race condition
1 parent ea42368 commit e6708ca

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/rx/internal/operators/OnSubscribeRedo.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import static rx.Observable.create;
3535

36-
import java.util.Random;
3736
import java.util.concurrent.atomic.AtomicBoolean;
3837
import java.util.concurrent.atomic.AtomicLong;
3938
import java.util.concurrent.atomic.AtomicReference;
@@ -376,10 +375,10 @@ public void request(final long n) {
376375
long c = BackpressureUtils.getAndAddRequest(consumerCapacity, n);
377376
Producer producer = currentProducer.get();
378377
if (producer != null) {
379-
// TODO what if at this point the subscription finishes and currentProducer
380-
// is set to null or even the next producer. The request would be added to consumerCapacity but
381-
// if more requests only come after emission then this call to the old producer could produce
382-
// nothing and the stream would stall
378+
// if at this point the subscription finishes and currentProducer
379+
// is set to null or even the next producer then we are still ok because even
380+
// though the producer may be inactive below, the resubscription that changed the
381+
// producer will call setProducer and request with consumerCapacity on the new producer.
383382
producer.request(n);
384383
} else
385384
if (c == 0 && resumeBoundary.compareAndSet(true, false)) {

0 commit comments

Comments
 (0)