RFR: 8267140: Support closing the HttpClient by making it auto-closable [v4]

Daniel Fuchs dfuchs at openjdk.org
Mon Mar 20 14:34:11 UTC 2023


On Mon, 20 Mar 2023 14:00:52 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 838:
> 
>> 836:      * The interrupt status will be re-asserted before this method returns.
>> 837:      *
>> 838:      * <p> If already terminated, invoking this method has no effect.
> 
> Should we also specify how this method behaves if this method is called (from a different thread, for example) when a previous invocation on this method is already currently in progress or is blocked waiting for operations to complete? Would the new invocation block too?

I don't think we need to specify anything additionally. The method invokes `shutdown`, which has no effect if already invoked, and then goes to waiting, which will wait until terminated. FWIW this is a word-for-word copy of `ExecutorService::close` - except that I may have substituted `task` with `request` or `operation`.

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

PR: https://git.openjdk.org/jdk/pull/13019


More information about the net-dev mailing list