Copilot commented on code in PR #3650:
URL: https://github.com/apache/maven-surefire/pull/3650#discussion_r4735649909


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java:
##########
@@ -271,11 +285,25 @@ protected void job() throws IOException, 
InterruptedException {
     }
 
     private AsynchronousSocketChannel getChannel() throws 
InterruptedException, IOException {
-        try {
-            return session == null ? null : session.get();
-        } catch (ExecutionException e) {
-            Throwable cause = e.getCause();
-            throw cause instanceof IOException ? (IOException) cause : new 
IOException(cause);
+        if (session == null) {
+            return null;
+        }
+        while (true) {
+            // Ask the process, not stdout: a fork may close its stdout and 
still connect later.
+            // Checked before waiting, so the fork still gets a second to 
connect.
+            // Only an error counts: a jvm wrapper script can start java in 
the background and exit 0.
+            boolean forkFailed = process != null && !process.isAlive() && 
process.exitValue() != 0;

Review Comment:
   With `argLine=-version`, the JVM exits with code 0 before connecting, so 
`forkFailed` remains false and this loop waits forever. The normal fork timeout 
does not apply until a test set starts. Add a bounded post-exit connection 
grace period that preserves delayed background-wrapper connections, and test a 
zero-exit process with no connecting child.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to