From 226b8e680a82096b3d268703872d30182c10e326 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 1 Aug 2022 13:44:21 +0000 Subject: [PATCH] 8290885: java/lang/ProcessBuilder/PipelineLeaksFD.java fail: More or fewer pipes than expected Reviewed-by: bpb, naoto, jpai --- test/jdk/ProblemList-Xcomp.txt | 1 - .../java/lang/ProcessBuilder/PipelineLeaksFD.java | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/jdk/ProblemList-Xcomp.txt b/test/jdk/ProblemList-Xcomp.txt index fea3e435160..df1b9da12b0 100644 --- a/test/jdk/ProblemList-Xcomp.txt +++ b/test/jdk/ProblemList-Xcomp.txt @@ -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 diff --git a/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java b/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java index 7094ac7f35a..4f572610b9d 100644 --- a/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java +++ b/test/jdk/java/lang/ProcessBuilder/PipelineLeaksFD.java @@ -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 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 pipesAfter = myPipes(); - printPipes(pipesAfter, "DEBUG: All Pipes After"); if (!pipesBefore.equals(pipesAfter)) { Set missing = new HashSet<>(pipesBefore); missing.removeAll(pipesAfter);