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

Daniel Fuchs dfuchs at openjdk.java.net
Mon Feb 22 16:49:50 UTC 2021


On Fri, 19 Feb 2021 19:34:26 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> 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?

I have reworked the ProxyServer to keep reusing the connection if it can detect that there will be no request body. If there is a request body and 407 is returned however, it will close the connection. That should leave things unchanged for tests that might have tried to use the ProxyServer for GET/HEAD requests. I suspect that no test was using it for POST as that obviously could not work if authentication was required. That said, all tests are passing :-)

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

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


More information about the net-dev mailing list