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 a08b3c96f921eb44e7c3cc1d492a7c3b1a6130d0 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Mon Oct 12 21:31:14 2026 +0000 Wait for the timed out fork to end on Java 8 On Java 8 the invoker cannot reach the Surefire fork, which kept files under target/ open until its own timeout; the workflow's clean step then failed on Windows. --- .../apache/maven/shared/invoker/DefaultInvokerTest.java | 16 ++++++++++++++++ .../java/org/apache/maven/shared/invoker/AppTest.java | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) 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 621c2eb..44cb1b8 100644 --- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java +++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java @@ -96,6 +96,10 @@ class DefaultInvokerTest { long length = heartbeat.length(); Thread.sleep(2000L); assertEquals(length, heartbeat.length(), "the forked test JVM is still running"); + } else { + // wait for the fixture's own timeout, so that no process of the nested build keeps files + // under target/ open: Windows cannot delete them, and a later clean of this project fails + awaitHeartbeatStopped(heartbeat); } // exitCode can't be used because in case of a timeout it's not correctly @@ -103,6 +107,18 @@ class DefaultInvokerTest { // assertEquals(1, result.getExitCode()); } + private static void awaitHeartbeatStopped(File heartbeat) throws InterruptedException { + long deadline = System.currentTimeMillis() + 60_000L; + long length = -1; + while (heartbeat.length() != length) { + assertTrue(System.currentTimeMillis() < deadline, "the forked test JVM did not end: " + heartbeat); + length = heartbeat.length(); + Thread.sleep(2000L); + } + // the heartbeat stops when the forked test fails on its timeout; give Maven a moment to exit after it + Thread.sleep(3000L); + } + @Test void spacePom() throws Exception { File basedir = getBasedirForBuild(); 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 9d7ee4e..5317c4f 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 @@ -30,7 +30,7 @@ public class AppTest * 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(timeout = 90000) + @Test(timeout = 45000) public void testApp() throws Exception { File heartbeat = new File( System.getProperty( "heartbeat" ) ); while (true) {
