8290885: java/lang/ProcessBuilder/PipelineLeaksFD.java fail: More or fewer pipes than expected

Reviewed-by: bpb, naoto, jpai
This commit is contained in:
Roger Riggs 2022-08-01 13:44:21 +00:00
parent 464085ed90
commit 226b8e680a
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -68,11 +68,18 @@ public class PipelineLeaksFD {
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();
@ -86,7 +93,6 @@ public class PipelineLeaksFD {
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);