提交 24c22ded 编写于 作者: R robm

8029525: java/lang/ProcessBuilder/Basic.java fails intermittently

Reviewed-by: alanb, chegar
Contributed-by: roger.riggs@oracle.com
上级 27e328ec
...@@ -2239,24 +2239,33 @@ public class Basic { ...@@ -2239,24 +2239,33 @@ public class Basic {
childArgs.add("sleep"); childArgs.add("sleep");
final Process p = new ProcessBuilder(childArgs).start(); final Process p = new ProcessBuilder(childArgs).start();
final long start = System.nanoTime(); final long start = System.nanoTime();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch ready = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
final Thread thread = new Thread() { final Thread thread = new Thread() {
public void run() { public void run() {
try { try {
final boolean result;
try { try {
latch.countDown(); ready.countDown();
p.waitFor(30000, TimeUnit.MILLISECONDS); result = p.waitFor(30000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
return; return;
} }
fail("waitFor() wasn't interrupted"); fail("waitFor() wasn't interrupted, its return value was: " + result);
} catch (Throwable t) { unexpected(t); }}}; } catch (Throwable t) {
unexpected(t);
} finally {
done.countDown();
}
}
};
thread.start(); thread.start();
latch.await(); ready.await();
Thread.sleep(1000); Thread.sleep(1000);
thread.interrupt(); thread.interrupt();
done.await();
p.destroy(); p.destroy();
} catch (Throwable t) { unexpected(t); } } catch (Throwable t) { unexpected(t); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册