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


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java:
##########
@@ -675,8 +682,9 @@ private RunResult fork(
             }
             forkClient.close(runResult.isTimeout());
 
-            if (runResult.isTimeout() && timeoutContextHolder[0] != null) {
-                
timeoutExtensionDispatcher.fireForkExited(timeoutContextHolder[0], runResult);
+            ForkedProcessTimeoutContext context = timeoutContext.get();
+            if (runResult.isTimeout() && context != null) {
+                timeoutExtensionDispatcher.fireForkExited(context, runResult);

Review Comment:
   `ForkClient.tryToTimeout()` marks the fork as timed out before this listener 
publishes its context. If the JVM exits naturally while PID resolution is still 
running, finalization can read a null context here and permanently skip the 
timeout extensions' `onForkExited()` callback. Coordinate finalization with 
context initialization; `AtomicReference` alone does not guarantee that 
initialization finishes before this check.



-- 
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