Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3.x: Fix toFlowable(ERROR) not cancelling on MBE
  • Loading branch information
akarnokd committed Sep 23, 2020
commit 4428e847b52fb289e61867ea987b1c1f68248539
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void onNext(T t) {
downstream.onNext(t);
BackpressureHelper.produced(this, 1);
} else {
upstream.cancel();
onError(new MissingBackpressureException("could not emit value due to lack of requests"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@

package io.reactivex.rxjava3.internal.operators.flowable;

import static org.junit.Assert.*;

import org.junit.Test;
import org.reactivestreams.Publisher;

import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.subjects.PublishSubject;
import io.reactivex.rxjava3.subscribers.TestSubscriber;
import io.reactivex.rxjava3.testsupport.TestHelper;

public class FlowableOnBackpressureErrorTest extends RxJavaTest {
Expand Down Expand Up @@ -51,4 +56,20 @@ public Object apply(Flowable<Integer> f) throws Exception {
}
}, false, 1, 1, 1);
}

@Test
public void overflowCancels() {
PublishSubject<Integer> ps = PublishSubject.create();

TestSubscriber<Integer> ts = ps.toFlowable(BackpressureStrategy.ERROR)
.test(0L);

assertTrue(ps.hasObservers());

ps.onNext(1);

assertFalse(ps.hasObservers());

ts.assertFailure(MissingBackpressureException.class);
}
}