RFR: 8267140: Support closing the HttpClient by making it auto-closable [v4]
Daniel Fuchs
dfuchs at openjdk.org
Mon Mar 20 14:16:16 UTC 2023
On Mon, 20 Mar 2023 12:56:15 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> 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 10 additional commits since the last revision:
>>
>> - Merge branch 'master' into HttpClient-close-8267140
>> - Update test/jdk/java/net/httpclient/HttpClientShutdown.java
>>
>> Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>
>> - Update test/jdk/java/net/httpclient/ShutdownNow.java
>>
>> Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>
>> - Update test/jdk/java/net/httpclient/HttpClientShutdown.java
>>
>> Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>
>> - Update test/jdk/java/net/httpclient/AsyncShutdownNow.java
>>
>> Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>
>> - Review feedback
>> - typo
>> - Merge branch 'master' into HttpClient-close-8267140
>> - Throw NPE if duration is null
>> - 8267140
>
> src/java.net.http/share/classes/java/net/http/HttpClient.java line 777:
>
>> 775: * See the API Note on {@linkplain ##closing closing}.
>> 776: *
>> 777: * @param duration the maximum time to wait
>
> Should this API have specific expectations when a negative or zero is passed as duration?
Good point. I borrowed this paragraph from `Thread::join`:
* <p> This method does not wait if the duration to wait is less than or
* equal to zero. In this case, the method just tests if the thread has
* terminated.
> src/java.net.http/share/classes/java/net/http/HttpClient.java line 780:
>
>> 778: * @return {@code true} if this client terminated and
>> 779: * {@code false} if the timeout elapsed before termination
>> 780: * @throws InterruptedException if interrupted while waiting
>
> The `HttpClient` class level javadoc doesn't state that it throws a `NullPointerException` from its methods, unless otherwise stated. So maybe we should explicitly add a `@throws NullPointerException` here?
The statement is in the `java.net.http` package level documentation. So `HttpClient` APIs are covered.
-------------
PR: https://git.openjdk.org/jdk/pull/13019
More information about the net-dev
mailing list