request(0) in Flow.Subscription and in SubmissionPublisher

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

request(0) in Flow.Subscription and in SubmissionPublisher

Dávid Karnok

according to the Reactive-Streams specification, requesting non-positive value is forbidden and must be rewarded with an onError:

> §3.9: While the Subscription is not cancelled, Subscription.request(long n) MUST signal onError with a java.lang.IllegalArgumentException if the argument is <= 0. The cause message MUST include a reference to this rule and/or quote the full rule.

However, the Flow.Subscription essentially ignores 0:

> If {@code n} is
> negative, the Subscriber will receive an {@code onError}
> signal with an {@link IllegalArgumentException} argument.
> Otherwise, the Subscriber will receive up to {@code n}
> additional {@code onNext} invocations (or fewer if
> terminated)

SubmissionPublisher<Integer> sp = new SubmissionPublisher<>(Runnable::run, 128);
Throwable[] err = { null };

sp.subscribe(new Flow.Subscriber<Integer>() {
public void onSubscribe(Flow.Subscription subscription) {

public void onNext(Integer item) {


public void onError(Throwable throwable) {
err[0] = throwable;

public void onComplete() {



Was this a deliberate change?

Best regards,
David Karnok

Concurrency-interest mailing list
[hidden email]