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. ------------- Commit messages: - 8347597: HttpClient: improve exception reporting when closing connection Changes: https://git.openjdk.org/jdk/pull/23080/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23080&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8347597 Stats: 219 lines in 15 files changed: 97 ins; 37 del; 85 mod Patch: https://git.openjdk.org/jdk/pull/23080.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/23080/head:pull/23080 PR: https://git.openjdk.org/jdk/pull/23080