You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2026/09/27 17:54:22 UTC
(maven-resolver) branch master updated: Fix flaky forked IPC client test (#2166)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new 75d5855f1 Fix flaky forked IPC client test (#2166)
75d5855f1 is described below
commit 75d5855f115ad5efcb9ff642ebeac0c1d2e45cfa
Author: Jitesh Khatri <ji...@gmail.com>
AuthorDate: Sun Sep 27 23:24:17 2026 +0530
Fix flaky forked IPC client test (#2166)
Fixes #2165.
The forked IPC server process can still hold the test log and repository
files when JUnit starts cleaning up the temporary directory on Windows.
Keep a reference to the forked Process and wait for it to terminate after
the server receives the stop request. If it does not terminate within the
timeout, forcibly terminate it and wait again.
This ensures the forked process has released its file handles before
temporary-directory cleanup.
Tests:
- IpcClientForkedTest#forkedServerDiagnosticsAreWrittenToLog: 20/20 runs passed
- maven-resolver-named-locks-ipc: 14/14 tests passed
- Checkstyle: 0 violations
- Spotless: clean
- RAT: clean
---
.../org/eclipse/aether/named/ipc/IpcClient.java | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcClient.java b/maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcClient.java
index ebeaf8f4e..5c31f8c95 100644
--- a/maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcClient.java
+++ b/maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcClient.java
@@ -90,6 +90,7 @@ public class IpcClient {
protected volatile DataOutputStream output;
protected volatile DataInputStream input;
protected volatile Thread receiver;
+ protected volatile Process process;
protected final AtomicInteger requestId = new AtomicInteger();
protected final Map<Integer, CompletableFuture<List<String>>> responses = new ConcurrentHashMap<>();
@@ -210,14 +211,14 @@ public class IpcClient {
ProcessBuilder processBuilder = new ProcessBuilder();
ProcessBuilder.Redirect discard = ProcessBuilder.Redirect.to(logFile.toFile());
Files.createDirectories(logPath);
- Process process = processBuilder
+ this.process = processBuilder
.directory(lockFile.getParent().toFile())
.command(args)
.redirectOutput(discard)
.redirectError(discard)
.start();
- writeBootstrapToken(process, rand);
- close = process::destroyForcibly;
+ writeBootstrapToken(this.process, rand);
+ close = this.process::destroyForcibly;
}
} else {
args.add(syncPath.resolve(syncCmd).toString());
@@ -233,14 +234,14 @@ public class IpcClient {
ProcessBuilder processBuilder = new ProcessBuilder();
ProcessBuilder.Redirect discard = ProcessBuilder.Redirect.to(logFile.toFile());
Files.createDirectories(logPath);
- Process process = processBuilder
+ this.process = processBuilder
.directory(lockFile.getParent().toFile())
.command(args)
.redirectOutput(discard)
.redirectError(discard)
.start();
- writeBootstrapToken(process, rand);
- close = process::destroyForcibly;
+ writeBootstrapToken(this.process, rand);
+ close = this.process::destroyForcibly;
}
ExecutorService es = Executors.newSingleThreadExecutor();
@@ -475,6 +476,17 @@ public class IpcClient {
if (response.size() != 1 || !RESPONSE_STOP.equals(response.get(0))) {
throw new IOException("Unexpected response: " + response);
}
+
+ Process forkedProcess = process;
+ if (forkedProcess != null) {
+ if (!forkedProcess.waitFor(30, TimeUnit.SECONDS)) {
+ forkedProcess.destroyForcibly();
+ if (!forkedProcess.waitFor(5, TimeUnit.SECONDS)) {
+ throw new IOException("Unable to stop forked server process");
+ }
+ }
+ process = null;
+ }
} catch (Exception e) {
close(e);
throw new RuntimeException("Unable to stop server", e);