This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch mvnd-1.x
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit 9a518a7f674d3b41c1c6e3828a83346486d3ea6f
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Nov 15 21:52:13 2026 +0100

    Close the stdin of the native client in the integration tests
    
    A mojo that reads System.in to the end waits for the end of input. The test 
left the pipe open, so the build never finished.
---
 .../java/org/mvndaemon/mvnd/junit/NativeTestClient.java    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java
 
b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java
index 6f3f7dc8..ebbc5b2d 100644
--- 
a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java
+++ 
b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java
@@ -19,6 +19,7 @@
 package org.mvndaemon.mvnd.junit;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -103,13 +104,14 @@ public class NativeTestClient implements Client {
         };
         try {
             final Process rawProcess = builder.start();
-            if (output instanceof TestClientOutput) {
-                final byte[] stdin = ((TestClientOutput) output).nativeStdin();
+            // Feed the process's real stdin, like piping data into a real 
mvnd invocation, and always close it:
+            // a mojo that reads System.in to the end would otherwise wait for 
input that never comes.
+            // The daemon talks to this spawned binary's own stdin, not to any 
in-JVM message queue.
+            try (OutputStream processStdin = rawProcess.getOutputStream()) {
+                final byte[] stdin =
+                        output instanceof TestClientOutput ? 
((TestClientOutput) output).nativeStdin() : null;
                 if (stdin != null) {
-                    // Feed the process's real stdin, like piping data into a 
real mvnd invocation.
-                    // The daemon talks to this spawned binary's own stdin, 
not to any in-JVM message queue.
-                    rawProcess.getOutputStream().write(stdin);
-                    rawProcess.getOutputStream().close();
+                    processStdin.write(stdin);
                 }
             }
             try (CommandProcess process =

Reply via email to