RFR: 8304962: sun/net/www/http/KeepAliveCache/B5045306.java: java.lang.RuntimeException: Failed: Initial Keep Alive Connection is not being reused

Jaikiran Pai jpai at openjdk.org
Tue Mar 28 06:52:31 UTC 2023


On Mon, 27 Mar 2023 19:38:01 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> This PR fixes intermittent test failures.
> 
> The test was broken by 95ca94436d12974d98b1b999f9cc8408d64cbe3c, which changed the `/firstCall` handler to return chunked response (second parameter to `sendResponseHeaders` was `0`). The test verifies the behavior of KeepAliveStreamCleaner, which only works on responses containing `Content-Length` header, and sometimes fails on chunked streams.
> 
> ~~Additionally I removed the unnecessary byte-to-character-to-byte conversion introduced in the same commit.~~
> Fixed the test server output. The PrintWriter printed the result of `toString()` call on a byte array instead of sending the byte array contents.
> 
> No failures after 50 test runs. Without the change the test failed 3 times in 10.

test/jdk/sun/net/www/http/KeepAliveCache/B5045306.java line 203:

> 201:                 trans.sendResponseHeaders(200, responseBody.length+1);
> 202:                 OutputStream os = trans.getResponseBody();
> 203:                 os.write(responseBody);

Hello Daniel, with this change, the OutputStream will no longer be explicitly closed before the exchange `trans` is closed. But I think that should be OK, because looking at the original code before https://github.com/openjdk/jdk/commit/95ca94436d12974d98b1b999f9cc8408d64cbe3c, it too wasn't closing it explicitly, as far as I can see it. So, this looks fine to me.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13194#discussion_r1150102871


More information about the net-dev mailing list