Copilot commented on code in PR #3650:
URL: https://github.com/apache/maven-surefire/pull/3650#discussion_r4729317380
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireForkChannel.java:
##########
@@ -271,11 +279,23 @@ 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) {
+ // The out thread reads the fork's stdout and ends once the fork
JVM is gone.
+ // Checked before waiting, so the fork still gets a second to
connect.
+ boolean forkAlive = out == null || out.isAlive();
Review Comment:
Stdout EOF or a read error can end `LineConsumerThread` while the fork is
still alive. If a launcher or Java agent closes stdout and delays the TCP
connection, this check can reject and destroy a healthy fork. Use an actual
process-exit signal from `ForkStarter`/`CommandlineExecutor` instead, and add a
regression test for a delayed connection after stdout EOF.
--
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]