-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b161
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8176984 | 10 | Doug Lea | P3 | Resolved | Fixed | b03 |
java.util.concurrent Flow is an implementation of reactive-streams specification and as such must conform to rule #9 for Subscription:
"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."
However, current javadoc states that:
/**
* Adds the given number {@code n} of items to the current
* unfulfilled demand for this subscription. 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).
*
* @param n the increment of demand; a value of {@code
* Long.MAX_VALUE} may be considered as effectively unbounded
*/
public void request(long n);
i.e. only negative values of n are treated as erroneous.
--------------------------------------------------------------------------------
This issues was created as a result of this discussion: http://cs.oswego.edu/pipermail/concurrency-interest/2017-March/015642.html
"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."
However, current javadoc states that:
/**
* Adds the given number {@code n} of items to the current
* unfulfilled demand for this subscription. 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).
*
* @param n the increment of demand; a value of {@code
* Long.MAX_VALUE} may be considered as effectively unbounded
*/
public void request(long n);
i.e. only negative values of n are treated as erroneous.
--------------------------------------------------------------------------------
This issues was created as a result of this discussion: http://cs.oswego.edu/pipermail/concurrency-interest/2017-March/015642.html
- backported by
-
JDK-8176984 Flow.Subscription.request(0) should be treated as an error
-
- Resolved
-