|
60 | 60 | * served on the container thread, so thread-locals set by servlet filters are visible to |
61 | 61 | * sync handlers; {@code subscriptions/listen} is served asynchronously. |
62 | 62 | * <p> |
| 63 | + * The MCP specification treats a client disconnect as cancellation of its request, but |
| 64 | + * the servlet API only reveals a disconnect when a write fails. A handler answering with |
| 65 | + * a plain result writes nothing until it is done, so it always runs to completion and its |
| 66 | + * result goes nowhere. A streaming response notices at its next message or keep-alive |
| 67 | + * (see {@link Builder#keepAliveInterval}) and cancels its body. Sync handler code is |
| 68 | + * blocking and is never interrupted, so a sync body keeps running until it returns; only |
| 69 | + * its output is dropped. Work that must stop when the client goes away belongs in an |
| 70 | + * async streaming response. |
| 71 | + * <p> |
63 | 72 | * Authentication and authorization, including {@code 401}/{@code 403} challenges, belong |
64 | 73 | * in servlet filters in front of this servlet. Filters may decide on the |
65 | 74 | * {@code Mcp-Method} and {@code Mcp-Name} headers: a request whose headers disagree with |
@@ -555,7 +564,8 @@ public Builder httpHeaderValidator(ServerHttpHeaderValidator httpHeaderValidator |
555 | 564 | /** |
556 | 565 | * How often an open event stream gets an SSE comment, keeping intermediaries from |
557 | 566 | * closing it and detecting clients that went away. {@code null} disables |
558 | | - * keep-alives. Defaults to 30 seconds. |
| 567 | + * keep-alives; a quiet stream then only notices a disconnect when its next |
| 568 | + * message fails to write. Defaults to 30 seconds. |
559 | 569 | */ |
560 | 570 | public Builder keepAliveInterval(Duration keepAliveInterval) { |
561 | 571 | Assert.isTrue(keepAliveInterval == null || !(keepAliveInterval.isNegative() || keepAliveInterval.isZero()), |
|
0 commit comments