FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: use Mono.when instead of Mono.zip for stdio readiness signals by k-krawczyk · Pull Request #987 · modelcontextprotocol/java-sdk · GitHub

Repository navigation

fix: use Mono.when instead of Mono.zip for stdio readiness signals - #987

Closed
k-krawczyk wants to merge 1 commit into
modelcontextprotocol:mainfrom
k-krawczyk:fix/stdio-mono-when-303
Closed

k-krawczyk wants to merge 1 commit into
modelcontextprotocol:mainfrom
k-krawczyk:fix/stdio-mono-when-303

Conversation

Copy link
Copy Markdown

Summary

Fixes #303.

StdioServerTransportProvider.sendMessage waited for the inbound and outbound streams to be ready using Mono.zip:

return Mono.zip(inboundReady.asMono(), outboundReady.asMono()).then(Mono.defer(() -> { ... }));

Both inboundReady and outboundReady are Sinks.One<Void> that complete empty (tryEmitValue(null)). Mono.zip requires every source to emit a value, and when one source completes without a value it short-circuits and cancels the remaining sources — exactly the behavior IntelliJ flagged in the issue. The consequence is that sendMessage could proceed as soon as the first readiness signal fired, cancelling the wait on the other, rather than waiting for both streams.

Mono.when is the correct combinator for completion-only (Mono<Void>) signals: it subscribes to all sources and completes only once all of them complete.

This matches the analysis and the reproduction in the issue.

Change

One-line operator swap: Mono.zip → Mono.when.

Testing

  • mcp-core compiles cleanly.
  • Existing StdioServerTransportProviderTests (9 tests) pass.

StdioServerTransportProvider.sendMessage waited on inbound/outbound
readiness with Mono.zip. Both inboundReady and outboundReady are
Sinks.One<Void> that complete empty (tryEmitValue(null)), and Mono.zip
requires every source to emit a value: when one source completes empty
it short-circuits and cancels the others. As a result sendMessage could
proceed before both streams were actually ready instead of waiting for
both.

Mono.when subscribes to all sources and completes only once all of them
complete, which is the correct combinator for completion-only
(Mono<Void>) signals.

Fixes modelcontextprotocol#303

Copy link
Copy Markdown
Author

Closing — already fixed by another contributor.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StdioServerTransportProvider uses incorrect Mono.zip operator

1 participant


Back | FazBrowse Home | New Git URL