RFR: 8252374: Add a new factory method to concatenate a sequence of BodyPublisher instances into a single publisher. [v4]
Chris Hegarty
chegar at openjdk.java.net
Fri Sep 18 11:37:56 UTC 2020
On Fri, 18 Sep 2020 09:01:56 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> Continuing the review with a PR...
>>
>> 8252374: Add a new factory method to concatenate a sequence
>> of BodyPublisher instances into a single publisher.
>> https://bugs.openjdk.java.net/browse/JDK-8252374
>>
>>
>> Draft CSR:
>> https://bugs.openjdk.java.net/browse/JDK-8252382
>
> Daniel Fuchs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev
> excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since
> the last revision:
> - Merge remote-tracking branch 'origin/master' into concat-bs-8252374
> - Merge remote-tracking branch 'origin/master' into concat-bs-8252374
> - Merge remote-tracking branch 'origin/master' into concat-bs-8252374
> - 8252374: Add a new factory method to concatenate a sequence of BodyPublisher instances into a single publisher.
src/java.net.http/share/classes/java/net/http/HttpRequest.java line 668:
> 666: * is returned. Otherwise each publisher is lazily subscribed to in turn,
> 667: * until all the body bytes are published, an error occurs, or the
> 668: * returned publisher's subscription is cancelled.
We should probably say what the publishers `contentLength` will return.
src/java.net.http/share/classes/java/net/http/HttpRequest.java line 661:
> 659:
> 660: /**
> 661: * Creates a {@code BodyPublisher} that publishes a request
Trivially, should we replace "Creates" with "Returns" to allow for the possibility of, say, a singleton empty publisher
(rather than having to "create" a new empty each time)
src/java.net.http/share/classes/java/net/http/HttpRequest.java line 680:
> 678: * cancelled}, or an error occurs while publishing the bytes, not all
> 679: * publishers in the sequence may be subscribed to.
> 680: * A publisher may be subscribed several times in sequence if the
I think that this sentence can be moved out of the implNote and into normative text
src/java.net.http/share/classes/java/net/http/HttpRequest.java line 688:
> 686: * by each publisher in the sequence.
> 687: */
> 688: public static BodyPublisher concat(BodyPublisher... publishers) {
It's a choice whether to allow an empty publishers array, or an array of just 1, or to disallow (throw
IllegalArgumentException), but that will depend on expected usage.
-------------
PR: https://git.openjdk.java.net/jdk/pull/57
More information about the net-dev
mailing list