Closed
Description
Rule 3.9 of Reactive Streams:
While the
Subscription
is not cancelled,Subscription.request(long n)
MUST signalonError
with ajava.lang.IllegalArgumentException
if the argument is <= 0. The cause message MUST include a reference to this rule and/or quote the full rule.
Current implementation of RxJava v2 seems to violate this rule in two places:
- Signal with
IllegalArgumentException
is delivered to theRxJavaPlugins.onError()
and not theSubscriber.onError()
.
Tests:
@Test
public void negativeRequestShouldSignalOnError() {
TestSubscriber<Integer> ts = TestSubscriber.create(0);
Flowable.just(1).subscribe(ts);
ts.request(-1);
ts.assertError(IllegalArgumentException.class);
}
@Test
public void zeroRequestShouldSignalOnError() {
TestSubscriber<Integer> ts = TestSubscriber.create(0);
Flowable.just(1).subscribe(ts);
ts.request(0);
ts.assertError(IllegalArgumentException.class);
}
- Cause message does not include reference to the rule nor quotes it.
Test:
@Test
public void illegalRequestShouldReferenceRuleOrQuoteIt() {
TestSubscriber<Integer> ts = TestSubscriber.create(0);
Flowable.just(1).subscribe(ts);
ts.request(-1);
String cause = ts.errors().get(0).getMessage();
assertTrue(cause.contains("3.9") || cause.contains("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. The intent of this rule is to prevent faulty implementations to proceed operation without any exceptions being raised. Requesting a negative or 0 number of elements, since requests are additive, most likely to be the result of an erroneous calculation on the behalf of the Subscriber."));
}
I can open two separate PRs to fix these violations if issue will be approved.
Metadata
Metadata
Assignees
Labels
No labels