RFR: 8267140: Support closing the HttpClient by making it auto-closable [v4]
Daniel Fuchs
dfuchs at openjdk.org
Mon Mar 20 14:07:16 UTC 2023
On Mon, 20 Mar 2023 12:54:39 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> src/java.net.http/share/classes/java/net/http/HttpClient.java line 769:
>>
>>> 767: /**
>>> 768: * Blocks until all operations have completed execution after a shutdown
>>> 769: * request, or the timeout occurs, or the current thread is
>>
>> If I understand this correctly, this method is expected to be called after `shutdown()` or `shutdownNow()` has been called. If so, then should this method throw an `IllegalStateException` if it gets called before any of those shutdown methods are called?
>
> Do you think we could reword this sentence to, to have necessary pointers to `duration` and thread interruption:
>
>> Blocks until all operations have completed execution after a shutdown request, or the {@code duration} passes, or the current thread is {@linkplain Thread#interrupt() interrupted}, whichever happens first.
> should this method throw an `IllegalStateException` if it gets called before any of those shutdown methods are called?
ExecutorService doesn't do that, and I don't think we should here either. The actual implementation of the method just joins the selector manager thread. There is no requirement that shutdown() and awaitTermination() are performed in the same thread, and no technical reason to prevent waiting before shutdown (especially if shutdown is triggered by some other thread).
> Do you think we could reword this sentence to, to have necessary pointers to duration and thread interruption:
Good idea.
-------------
PR: https://git.openjdk.org/jdk/pull/13019
More information about the net-dev
mailing list