Merge
This commit is contained in:
commit
8972c391cb
@ -496,12 +496,11 @@ final class ProcessImpl extends Process {
|
||||
public synchronized boolean waitFor(long timeout, TimeUnit unit)
|
||||
throws InterruptedException
|
||||
{
|
||||
long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions
|
||||
if (hasExited) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long remainingNanos = unit.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + remainingNanos;
|
||||
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
wait(TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L));
|
||||
|
@ -458,12 +458,11 @@ final class ProcessImpl extends Process {
|
||||
public boolean waitFor(long timeout, TimeUnit unit)
|
||||
throws InterruptedException
|
||||
{
|
||||
long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions
|
||||
if (getExitCodeProcess(handle) != STILL_ACTIVE) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long remainingNanos = unit.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + remainingNanos ;
|
||||
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
|
||||
|
@ -27,6 +27,7 @@
|
||||
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
|
||||
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
|
||||
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
|
||||
* 8067796
|
||||
* @summary Basic tests for Process and Environment Variable code
|
||||
* @run main/othervm/timeout=300 Basic
|
||||
* @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic
|
||||
@ -2386,6 +2387,56 @@ public class Basic {
|
||||
p.destroy();
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check that Process.waitFor(timeout, null) throws NPE.
|
||||
//----------------------------------------------------------------
|
||||
try {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("sleep");
|
||||
final Process p = new ProcessBuilder(childArgs).start();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
// Terminate process and recheck after it exits
|
||||
p.destroy();
|
||||
p.waitFor();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check that default implementation of Process.waitFor(timeout, null) throws NPE.
|
||||
//----------------------------------------------------------------
|
||||
try {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("sleep");
|
||||
final Process proc = new ProcessBuilder(childArgs).start();
|
||||
final DelegatingProcess p = new DelegatingProcess(proc);
|
||||
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
// Terminate process and recheck after it exits
|
||||
p.destroy();
|
||||
p.waitFor();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check the default implementation for
|
||||
// Process.waitFor(long, TimeUnit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user