You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 84c50c3
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -574,21 +574,23 @@ try (var server = OpenApiServer.builder()
574
574
`stop(int)` and `shutdownTimeoutSeconds(int)` reject negative values with
575
575
`IllegalArgumentException`.
576
576
577
-
Stopping closes the listening socket at once, so no new connection is accepted. Requests on
578
-
keep-alive connections that are already open are served until the JDK sees no exchange in flight,
579
-
which can come before the after-response runnables of the last request have finished; the JDK then
580
-
closes every connection, keep-alive ones included. The wait ends as soon as `inFlightRequests()` reads `0`, or when the delay elapses; every connection
581
-
is then closed, which cuts off what is still running. A request counts as in flight from the first
582
-
filter until its after-response runnables (`Request.afterResponse`, hooks) have run, so `stop` waits
583
-
for those too. A request the JDK rejects before it dispatches it, such as a malformed one, is not
584
-
counted.
577
+
Stopping closes the listening socket at once, so no new connection is accepted.
578
+
Requests on keep-alive connections that are already open are still served
579
+
until the JDK sees no exchange in flight.
580
+
The wait ends as soon as `inFlightRequests()` reads `0`, or when the delay elapses.
581
+
Every connection is then closed, which cuts off what is still running.
582
+
A request counts as in flight from the first filter
583
+
until its after-response runnables (`Request.afterResponse`, hooks) have run,
584
+
so `stop` waits for those too.
585
+
A request the JDK rejects before it dispatches it, such as a malformed one, is not counted.
585
586
586
587
Only the first `stop` call stops the server. A later or concurrent call waits until that stop is
587
588
complete, then returns (or throws `IllegalStateException` if that stop failed); its own delay is
588
589
ignored. A thread interrupted while it waits stops waiting and keeps its interrupt flag.
589
590
590
-
`inFlightRequests()` is the server's own count, readable at any time, for example to log it or to
591
-
wait for `0` before stopping.
591
+
`inFlightRequests()` is a snapshot of the server's own count, readable at any time,
592
+
for example for logs and metrics.
593
+
To drain before shutdown, call `stop(int)`, which waits for the count itself.
0 commit comments