From c23d37e10a429c0e7248593b07ef1ccdcd34bd1c Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Mon, 29 Jul 2024 16:43:25 +0000 Subject: [PATCH] 8337300: java/lang/Process/WaitForDuration.java leaves child process behind Reviewed-by: alanb, iris, bpb --- test/jdk/java/lang/Process/WaitForDuration.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/lang/Process/WaitForDuration.java b/test/jdk/java/lang/Process/WaitForDuration.java index d9172b305a0..76c69e36d13 100644 --- a/test/jdk/java/lang/Process/WaitForDuration.java +++ b/test/jdk/java/lang/Process/WaitForDuration.java @@ -55,9 +55,14 @@ public class WaitForDuration { @MethodSource("durations") void testEdgeDurations(Duration d, int sleepMillis, boolean expected) throws IOException, InterruptedException { - var pb = ProcessTools.createTestJavaProcessBuilder( - WaitForDuration.class.getSimpleName(), Integer.toString(sleepMillis)); - assertEquals(expected, pb.start().waitFor(d)); + var child = ProcessTools.createTestJavaProcessBuilder( + WaitForDuration.class.getSimpleName(), Integer.toString(sleepMillis)) + .start(); + try { + assertEquals(expected, child.waitFor(d)); + } finally { + child.destroy(); + } } @Test