RFR: 8355370: Include server name in HTTP test server thread names to improve diagnostics

Volkan Yazici vyazici at openjdk.org
Wed Apr 23 10:24:13 UTC 2025


Incorporates the test server name while deriving the HTTP/2 test server (i.e., `jdk.httpclient.test.lib.http2.Http2TestServer`) thread names to improve diagnostics.

### Making `HttpTestServer` implement `AutoCloseable`

I carried out this out-of-scope enhancement along with this PR, since this one-liner gives nice try-with-resources convenience while writing tests using HTTP test servers. Note that [this change is already implemented for the in-progress HTTP/3 work](/dfuch/jdk/blob/9c2da664d2875b7e7986831fd716d05b7a8306f4/test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/common/HttpServerAdapters.java#L1119).

### Avoiding to improve HTTP/1.1 server thread names

We deliberately kept improving HTTP/1.1 server (shipped by `jwebserver` and delegated to for HTTP/1.1 server needs of `HttpClient` tests) thread names out of the scope in this story. `ServerImpl`, the default HTTP/1.1 server implementation, has only one thread by default: the dispatcher and it is named `HTTP-Dispatcher`. Since factory methods in `com.sun.net.httpserver.Http[s]Server` don't have the notion of a _name_, it will be a rather big change to introduce a `name` there. We could have opted for including host & port information in the `ServerImpl` dispatcher thread name, but that might expose sensitive information.

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

Commit messages:
 - Make `HttpTestServer` implement `AutoCloseable`
 - Remove redundant branching in `createExecutor`
 - Use `Thread.ofPlatform()` builder
 - Shorten thread name
 - Move `createExecutor` up
 - Move `createExecutor` to `Http2TestServer`
 - Improve canonical ctor usage in `Http2TestServer`
 - Revert `ServerImpl` changes
 - Improve HTTP server thread naming

Changes: https://git.openjdk.org/jdk/pull/24822/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24822&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8355370
  Stats: 21 lines in 2 files changed: 6 ins; 6 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/24822.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24822/head:pull/24822

PR: https://git.openjdk.org/jdk/pull/24822


More information about the net-dev mailing list