Mercurial > hg > openjdk > jdk8 > jdk
changeset 8954:72ea199e3e1b
8029525: java/lang/ProcessBuilder/Basic.java fails intermittently
Reviewed-by: alanb, chegar
Contributed-by: roger.riggs@oracle.com
author | robm |
---|---|
date | Thu, 05 Dec 2013 16:19:06 +0000 |
parents | 303f4bccfca2 |
children | 7ecaa4402c4e f8da1f34c65c |
files | test/java/lang/ProcessBuilder/Basic.java |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/test/java/lang/ProcessBuilder/Basic.java Thu Dec 05 07:45:27 2013 -0800 +++ b/test/java/lang/ProcessBuilder/Basic.java Thu Dec 05 16:19:06 2013 +0000 @@ -2239,24 +2239,33 @@ childArgs.add("sleep"); final Process p = new ProcessBuilder(childArgs).start(); 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() { public void run() { try { + final boolean result; try { - latch.countDown(); - p.waitFor(30000, TimeUnit.MILLISECONDS); + ready.countDown(); + result = p.waitFor(30000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { return; } - fail("waitFor() wasn't interrupted"); - } catch (Throwable t) { unexpected(t); }}}; + fail("waitFor() wasn't interrupted, its return value was: " + result); + } catch (Throwable t) { + unexpected(t); + } finally { + done.countDown(); + } + } + }; thread.start(); - latch.await(); + ready.await(); Thread.sleep(1000); thread.interrupt(); + done.await(); p.destroy(); } catch (Throwable t) { unexpected(t); }