Skip to content

Commit 226b8e6

Browse files
author
Roger Riggs
committed
8290885: java/lang/ProcessBuilder/PipelineLeaksFD.java fail: More or fewer pipes than expected
Reviewed-by: bpb, naoto, jpai
1 parent 464085e commit 226b8e6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

test/jdk/ProblemList-Xcomp.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929

3030
java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all
3131
java/lang/ref/ReferenceEnqueue.java 8284236 generic-all
32-
java/lang/ProcessBuilder/PipelineLeaksFD.java 8290885 generic-all

test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,18 @@ void checkForLeaks(List<ProcessBuilder> builders) throws IOException {
6868
Assert.fail("There should be at least 3 pipes before, (0, 1, 2)");
6969
}
7070

71+
// Redirect all of the error streams to stdout (except the last)
72+
// so those file descriptors are not left open
73+
for (int i = 0; i < builders.size() - 1; i++) {
74+
builders.get(i).redirectErrorStream(true);
75+
}
76+
7177
List<Process> processes = ProcessBuilder.startPipeline(builders);
7278

73-
OutputStream out = processes.get(0).getOutputStream();
74-
out.write('a');
75-
out.close();
79+
// Write something through the pipeline
80+
try (OutputStream out = processes.get(0).getOutputStream()) {
81+
out.write('a');
82+
}
7683

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

8895
Set<PipeRecord> pipesAfter = myPipes();
89-
printPipes(pipesAfter, "DEBUG: All Pipes After");
9096
if (!pipesBefore.equals(pipesAfter)) {
9197
Set<PipeRecord> missing = new HashSet<>(pipesBefore);
9298
missing.removeAll(pipesAfter);

0 commit comments

Comments
 (0)