RFR: 8262027: Improve how HttpConnection detects a closed channel when taking/returning a connection to the pool [v2]

Michael McMahon michaelm at openjdk.java.net
Fri Feb 19 19:37:40 UTC 2021


On Fri, 19 Feb 2021 18:58:21 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> test/jdk/java/net/httpclient/ProxyServer.java line 390:
>> 
>>> 388:                             clientSocket.shutdownInput();
>>> 389:                             close();
>>> 390:                             return;
>> 
>> I realise it isn't related to this change, but why is the test proxy closing the connection?
>
> There's no guarantee that the proxy will have read all the bytes sent by the client - even if it attempts to drain the connection. So the only sane reaction if you're not going to parse the request body is to close the connection.

Right, I was mistaken. It actually is related to this change. You are testing what happens *if* the proxy closes the connection. Though that wouldn't be normal behavior for a proxy. If you are sending 407 to the client then you would want to keep the connection open so the client can retry the request. Maybe we need some comments in ProxyServer to indicate that the connection is being closed to test this specific scenario. Though if ProxyServer is used in other tests, I wonder if it might be better to use some flag or switch to enable this connection closing behavior?

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

PR: https://git.openjdk.java.net/jdk/pull/2649


More information about the net-dev mailing list