RFR: 8304065: HttpServer.stop should terminate immediately if no exchanges are in progress

Eirik Bjørsnøs eirbjo at openjdk.org
Sat Apr 5 11:08:31 UTC 2025


Please help review this PR which improves `HttpServer::stop` termination timing to better fit user expectations.

This PR:

* Makes `ServerImpl::stop` continue without delay when there are no active exchanges during shutdown
* Attempts to interrupt the dispatcher thread before joining it, giving long-living interruptible exchanges a chance to finish  early
* Adds testing for boundary conditions with or without an active exchange, delay occurring before exhange completes and exchange completing before delay.

Additinally, `ServerImpl::stop` is updated to use `System::nanotime` instead of `System::currentTimeMillis` when calculating wait times.

The test relies on timing to assert the order of events. Not perfect, but it seems to work.

(This part of the code base is rather new to me. A bit of hand-holding should be expected when reviewing this PR)

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

Commit messages:
 - Improve shutdown sequence in HttpServerImpl::stop

Changes: https://git.openjdk.org/jdk/pull/24467/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24467&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8304065
  Stats: 237 lines in 2 files changed: 231 ins; 3 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/24467.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24467/head:pull/24467

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


More information about the net-dev mailing list