RFR: 8288717: Add a means to close idle connections in HTTP/2 connection pool [v5]
Conor Cleary
ccleary at openjdk.org
Thu Nov 3 16:41:36 UTC 2022
On Thu, 3 Nov 2022 16:28:08 GMT, Conor Cleary <ccleary at openjdk.org> wrote:
>> **Issue**
>> When using HTTP/2 with the HttpClient, it can often be necessary to close an idle Http2 Connection before a server sends a GOAWAY frame. For example, a server or cloud based tool could close a TCP connection silently when it is idle for too long resulting in ConnectionResetException being thrown by the HttpClient.
>>
>> **Proposed Solution**
>> A new system property, `jdk.httpclient.idleConnectionTimeout`, was added and is used to specify in Milliseconds how long an idle connection (idle connections are those which have no currently active streams) for the HttpClient before the connection is closed.
>
> Conor Cleary has updated the pull request incrementally with one additional commit since the last revision:
>
> 8288717: IdleConnectionTimeout can use Keep Alive or Custom Value
A summary of the most recent changes to this PR.
1. shutdown() in Http2Connection is returned to its original form. The existing code there is sufficient to log the idleConnectionTimeoutEvent once it fires.
2. ConnectionPool now gets it's Keep-Alive Timeout Value from HttpClientImpl using the `jdk.httpclient.keepalive.timeout` property. As well as this, the idleConnectionTimeoutEvent also gets its value from the same KeepAlive property. However, if the developer wishes to use different timeout values for HTTP/1 vs HTTP/2, they can use the new `jdk.httpclient.keepalive.timeout.h2` property to specify this.
3. getTimeoutProp() was added to HttpClientImpl to account for erroneous input possibly given to either the Keep-Alive or Idle Conection Timout Values.
4. The test has been changed to reflect the above two changes and to test for erroneous input. When input is erroneous, default values are used.
One thing I would like to discuss here is the naming of the property used to override the value passed to the IdleConnectionTimeoutEvent as mentioned in the second point above. Perhaps something more meaningful to http2 and the idleConnectionTimeoutEvent could be used instead of `jdk.httpclient.keepalive.timeout.h2`?
Thanks all for the feedback so far, hopefully this can get closed off soon!
-------------
PR: https://git.openjdk.org/jdk/pull/10183
More information about the net-dev
mailing list