Skip to content

Commit 4f41ebd

Browse files
committed
fix(mcp): capture connected child safely
1 parent 6e3e74c commit 4f41ebd

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/main/java/io/github/easy4j/comfy/mcp/ComfyMcpClient.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ public synchronized String connect() {
108108
Process child = null;
109109
try {
110110
child = builder.start();
111-
process = child;
112-
stdin = new PrintWriter(new OutputStreamWriter(child.getOutputStream(), StandardCharsets.UTF_8), true);
111+
final Process connectedChild = child;
112+
process = connectedChild;
113+
stdin = new PrintWriter(new OutputStreamWriter(connectedChild.getOutputStream(), StandardCharsets.UTF_8), true);
113114

114-
stdoutReader = daemon("comfy-mcp-reader", () -> readLoop(child));
115-
stderrReader = daemon("comfy-mcp-stderr", () -> drainStderr(child));
115+
stdoutReader = daemon("comfy-mcp-reader", () -> readLoop(connectedChild));
116+
stderrReader = daemon("comfy-mcp-stderr", () -> drainStderr(connectedChild));
116117
stdoutReader.start();
117118
stderrReader.start();
118119

0 commit comments

Comments
 (0)