modelcontextprotocol / modelcontextprotocol/java-sdk
StdioClientTransport: Inbound Scheduler and Error Scheduler threads are locked on Windows
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 3.7k
- フォーク
- 1.1k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 9
説明
Bug description
Two threads, Inbound Scheduler and Error Scheduler, remain locked forever (at java.io.FileInputStream.readBytes native call) in io.modelcontextprotocol.client.transport.StdioClientTransport after the graceful shutdown is completed using closeGracefully method.
Looks like a Windows specific issue with native I/O calls. The problem is observed when running on Windows. No problems with Linux environment.
The thread dump is attached.
dump_jdk17.txt
See "pool-2-thread-1" and "pool-5-thread-1" dumps.
Environment
Windows 11 Enterprise
mcp-core 0.17.1
Spring AI 2.0.0-SNAPSHOT
JDK Temurin 17.0.14 (also tried Amazon Corretto 21.0.5)
Linux Behavior
Works fine under Ubuntu 24.04 and JDK Temurin 21.0.10
Steps to reproduce
- Run the steps from the Spring AI Filesystem Demo example on Windows.
- The Java application process is not terminated as expected.
Expected behavior
The Java process terminates after running the Spring AI Filesystem Demo example.
Possible solution
On Windows, use daemon threads for inbound and error schedulers
private ThreadFactory daemonThreadFactory = runnable -> {
Thread t = new Thread(runnable);
t.setDaemon(true);
return t;
};
if (isWindows) {
this.inboundScheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(daemonThreadFactory), "inbound");
this.errorScheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(daemonThreadFactory), "error");
}
Tried this solution locally. It resolves the termination issue. But the graceful shutdown logic in io.modelcontextprotocol.client.transport.StdioClientTransport#closeGracefully should be revised as well.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
io.modelcontextprotocol.client.transport.StdioClientTransport から開始し、Inbound Scheduler、Error Scheduler、closeGracefully メソッドに重点を置いてから、添付された Windows スレッドダンプを確認してブロックされた読み取りを調査します。Windows 上で Spring AI Filesystem Demo を再現し、シャットダウンによって Java プロセスが終了し、scheduler スレッドがロックされたままにならないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100