On Mon, 13 Jan 2025 16:07:45 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:

> There are a few places in the HttpClient code base where we close the 
> connection when some error/exception happens. This can some time trigger a 
> race condition where closing the connection in turns causes a "connection 
> closed locally" exception to get reported instead of the original exception. 
> This typically happens if another thread is attempting to read from / write 
> to the connection concurrently when the original exception that caused the 
> connection to get closed occurred. 
> 
> The fix makes sure that we store the first exception in the underlying 
> connection before closing it, and that this is the exception that gets 
> subsequently reported.
> 
> Some minor drive by test fixes. No new regression test.

test/jdk/java/net/httpclient/http2/ExpectContinueResetTest.java line 104:

> 102:             testThrowable = e.getCause();
> 103:         }
> 104:         assertNotNull(exception, "Request should have completed 
> exceptionally but exception is null");

Unlike the `assertNotNull` on the next line, I think it might be better to 
replace this new `assertNotNull` with a `fail(...)` inside the try block 
immediately after the `performRequest()` call.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23080#discussion_r1914555193

Reply via email to