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

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

commit 7d8b735c2c1b0144dbcd024c61057cbaee085f49
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Sep 21 15:03:06 2026 +0200

    Keep the timeout test meaningful on Java 8, where the descendants cannot be 
reached
---
 .../apache/maven/shared/invoker/DefaultInvokerTest.java    | 14 +++++++++-----
 .../test/java/org/apache/maven/shared/invoker/AppTest.java |  6 +++---
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java 
b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
index 9dfe441..621c2eb 100644
--- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
@@ -30,6 +30,7 @@ import org.apache.maven.shared.utils.StringUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.JRE;
 import org.junit.jupiter.api.condition.OS;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -87,12 +88,15 @@ class DefaultInvokerTest {
         // We check the exception to be sure the failure is based on timeout.
         assertTrue(result.getExecutionException().getMessage().contains("timed 
out"));
 
-        // the Surefire fork under the timed out Maven must be gone too 
(MSHARED-867), so its heartbeat stops
+        // the Surefire fork under the timed out Maven must be gone too 
(MSHARED-867), so its heartbeat stops;
+        // only Java 9+ can reach the descendants (ProcessHandle), on Java 8 
the fixture ends itself
         assertTrue(heartbeat.isFile(), "the forked test never started: " + 
heartbeat);
-        Thread.sleep(1000L);
-        long length = heartbeat.length();
-        Thread.sleep(2000L);
-        assertEquals(length, heartbeat.length(), "the forked test JVM is still 
running");
+        if (JRE.currentVersion().compareTo(JRE.JAVA_8) > 0) {
+            Thread.sleep(1000L);
+            long length = heartbeat.length();
+            Thread.sleep(2000L);
+            assertEquals(length, heartbeat.length(), "the forked test JVM is 
still running");
+        }
 
         // exitCode can't be used because in case of a timeout it's not 
correctly
         // set in DefaultInvoker. Need to think about this.
diff --git 
a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
 
b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
index 9933b06..9d7ee4e 100644
--- 
a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
+++ 
b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
@@ -27,10 +27,10 @@ import org.junit.Test;
 public class AppTest
 {
     /**
-     * Never ends on its own: the invoker's timeout has to stop this forked 
JVM. The heartbeat file lets the
-     * invoker test see whether it did.
+     * Runs until the invoker's timeout stops this forked JVM, which the 
heartbeat file lets the invoker test see;
+     * the test's own timeout is the safety net for a Java 8 invoker, which 
cannot reach this process.
      */
-    @Test
+    @Test(timeout = 90000)
     public void testApp() throws Exception {
         File heartbeat = new File( System.getProperty( "heartbeat" ) );
         while (true) {

Reply via email to