RFR: 8291637: HttpClient default keep alive timeout not followed if server sends invalid value

Michael McMahon michaelm at openjdk.org
Fri Aug 5 09:04:02 UTC 2022


On Fri, 5 Aug 2022 06:28:33 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Hi,
>> 
>> Some new keep alive tests are exposing some old bugs. In this case if the server sends an invalid timeout (say -20 seconds) we accept it creating a timeout in the past. So, the first time the keep alive thread wakes up it will close the connection.
>> The correct behavior is to ignore the invalid parameter and fallback to the default timeout or the timeout set by the relevant system property.
>> 
>> Thanks,
>> Michael
>
> src/java.base/share/classes/sun/net/www/http/HttpClient.java line 902:
> 
>> 900:                             responses.findValue("Keep-Alive"));
>> 901:                         /* default should be larger in case of proxy */
>> 902:                         keepAliveConnections = p.findInt("max", usingProxy?50:5);
> 
> Hello Michael, should we do something similar for this `max` parameter value too and (re)set the `keepAliveConnections` to the defaults, if the server sends a negative value?

Yes, that's a good suggestion. Will do.

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

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


More information about the net-dev mailing list