Properly dispose Schedulers for IO and skip closing BufferedReader as they deadlocked on Ubuntu
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@gmail.com>
This commit is contained in:
parent
a4950c04a5
commit
8397849d6e
1 changed files with 7 additions and 25 deletions
|
|
@ -253,31 +253,13 @@ public class StdioServerTransport extends AbstractMcpTransport {
|
|||
if (process.exitValue() != 0) {
|
||||
System.out.println("Process terminated with code " + process.exitValue());
|
||||
}
|
||||
}).then(Mono.whenDelayError(Mono.fromRunnable(() -> {
|
||||
try {
|
||||
this.processErrorReader.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}), Mono.fromRunnable(() -> {
|
||||
try {
|
||||
this.processReader.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}), Mono.fromRunnable(() -> {
|
||||
try {
|
||||
this.processWriter.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})))
|
||||
.then(Mono.whenDelayError(inboundScheduler.disposeGracefully(), outboundScheduler.disposeGracefully(),
|
||||
errorScheduler.disposeGracefully()))
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
}).then(Mono.fromRunnable(() -> {
|
||||
// The Threads are blocked on readLine so disposeGracefully would not
|
||||
// interrupt them, therefore we issue an async hard dispose.
|
||||
inboundScheduler.dispose();
|
||||
errorScheduler.dispose();
|
||||
outboundScheduler.dispose();
|
||||
})).then().subscribeOn(Schedulers.boundedElastic());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue