modelcontextprotocol / modelcontextprotocol/java-sdk
StdioClientTransport: Inbound Scheduler and Error Scheduler threads are locked on Windows
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 3.7k
- Forks
- 1.1k
- Merge moyen
- 1 j 15 h
- PR mergées (30 j)
- 9
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par io.modelcontextprotocol.client.transport.StdioClientTransport, en vous concentrant sur l’Inbound Scheduler, l’Error Scheduler et la méthode closeGracefully, puis examinez le thread dump Windows joint pour rechercher les lectures bloquées. Reproduisez Spring AI Filesystem Demo sous Windows et vérifiez que l’arrêt termine le processus Java sans laisser de threads du scheduler verrouillés.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100