RFR: 8252304: Seed an HttpRequest.Builder from an existing HttpRequest [v3]

Mark Sheppard msheppar at openjdk.java.net
Mon Nov 9 18:40:58 UTC 2020


On Mon, 9 Nov 2020 10:28:08 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>>> /csr
>> 
>> Link to CSR: https://bugs.openjdk.java.net/browse/JDK-8255993
>
> I wonder if the spec should be a little more specific than just "seeded" which I think is fine for the first sentence. But maybe say something like "fields are copied from the given HttpRequest" in the description.

a couple of points:
Should the spec state explicitly that an NPE is thrown if the supplied HttpRequest reference is null?

Alternatively, if the supplied HttpRequest is null then why not return an empty builder?

I would favour a slightly more verbose statement in the spec, something like:

   /**
     * Creates a {@code Builder} with its pre request state set from that of an existing {@code HttpRequest}.
     *
     * <p> This method can be used as the basis for building a new request equivalent to a
     * given request, while allowing further amendment and alteration of 
     * the pre request state, for example adding additional Http headers, prior to request construction.
     *
     * @param request the request
     * @return a new request builder
     * @throws IllegalArgumentException if a new builder cannot be seeded from
     *         the given request (for instance, if the request contains illegal
     *         parameters)
     * @throws NullPointerException is thrown if the supplied HttpRequest is null
     * @since 16
     */

-------------

PR: https://git.openjdk.java.net/jdk/pull/1059


More information about the net-dev mailing list