Skip to content

Commit

Permalink
8290885: java/lang/ProcessBuilder/PipelineLeaksFD.java fail: More or …
Browse files Browse the repository at this point in the history
…fewer pipes than expected

Reviewed-by: bpb, naoto, jpai
  • Loading branch information
Roger Riggs committed Aug 1, 2022
1 parent 464085e commit 226b8e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList-Xcomp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@

java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all
java/lang/ref/ReferenceEnqueue.java 8284236 generic-all
java/lang/ProcessBuilder/PipelineLeaksFD.java 8290885 generic-all
14 changes: 10 additions & 4 deletions test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@ void checkForLeaks(List<ProcessBuilder> builders) throws IOException {
Assert.fail("There should be at least 3 pipes before, (0, 1, 2)");
}

// Redirect all of the error streams to stdout (except the last)
// so those file descriptors are not left open
for (int i = 0; i < builders.size() - 1; i++) {
builders.get(i).redirectErrorStream(true);
}

List<Process> processes = ProcessBuilder.startPipeline(builders);

OutputStream out = processes.get(0).getOutputStream();
out.write('a');
out.close();
// Write something through the pipeline
try (OutputStream out = processes.get(0).getOutputStream()) {
out.write('a');
}

Process last = processes.get(processes.size() - 1);
try (InputStream inputStream = last.getInputStream();
Expand All @@ -86,7 +93,6 @@ void checkForLeaks(List<ProcessBuilder> builders) throws IOException {
processes.forEach(p -> waitForQuiet(p));

Set<PipeRecord> pipesAfter = myPipes();
printPipes(pipesAfter, "DEBUG: All Pipes After");
if (!pipesBefore.equals(pipesAfter)) {
Set<PipeRecord> missing = new HashSet<>(pipesBefore);
missing.removeAll(pipesAfter);
Expand Down

1 comment on commit 226b8e6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.