Servlet transports block Tomcat thread
Maintainer antworten meist innerhalb von 3 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Beginne mit HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider und HttpServletStatelessServerTransport und verfolge, an welchen Stellen eingehende Requests .block() aufrufen und wie AsyncContext verwendet wird. Vergleiche die Pfade von SyncToolSpecification und AsyncToolSpecification und überprüfe anschließend, dass die Request-Threads freigegeben werden, während die reaktive Operation fortgesetzt und erfolgreich abgeschlossen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug Description
All Servlet-based transports in the SDK (e.g., HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider, HttpServletStatelessServerTransport) call .block() on the Tomcat request thread when processing incoming HTTP requests.
Although AsyncContext is used to hold connections for SSE/streaming, the Tomcat thread remains parked until tool execution completes. As a result, the reactive/async architecture does not provide any real thread efficiency: the request thread stays blocked for the entire duration of the tool call.
With SyncToolSpecification and immediateExecution=false, the tool handler is executed on a separate thread (typically from the boundedElastic pool). This prevents blocking logic from running on the Tomcat thread itself, but the request thread still remains blocked waiting for completion.
With AsyncToolSpecification(via McpAsyncServer), handlers are expected to return fully asynchronous operations (e.g., non-blocking I/O). However, because the transport calls .block(), the HTTP request handling remains synchronous. The handler is not automatically scheduled on another thread unless the developer explicitly does so.
As a result, both SyncToolSpecification and AsyncToolSpecification ultimately block the Tomcat request thread until completion.
I’m not sure if this behavior is intentional. Based on the design of McpAsyncServer, I would expect the transport layer to release the Tomcat thread immediately and allow the reactive pipeline to complete asynchronously. (AsyncContext + subscribe).
@pratik2294
- Vorherrschende Sprache
- Java
- Sterne
- 3.7k
- Forks
- 1.1k
- Ø Merge
- 2 T. 5 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/java-sdk
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
modelcontextprotocol/java-sdk#1155 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
area/client bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
modelcontextprotocol/java-sdk#1124 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 3 Tagen
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilitiesOffenbug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/java-sdk#1086 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
enhancement good first issue P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
modelcontextprotocol/java-sdk#1067 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug P2 ready for work
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
modelcontextprotocol/java-sdk#898 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in modelcontextprotocol/java-sdk
Ähnliche Issues
-
Update license yearOffen0 - Backlog 1 - Ready documentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
cbor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
FasterXML/jackson-dataformats-binary#844 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Issue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
OpenAPITools/openapi-generator#25107 ·
Maintainer antworten meist innerhalb von 1 Tag
-
improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/iceberg#18351 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
repowise-dev/repowise#2945 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag