mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8168414: Various timeouthandler fixes
Reviewed-by: mlarsson
This commit is contained in:
parent
5320830885
commit
6594e9ed40
2 changed files with 23 additions and 20 deletions
|
@ -94,6 +94,7 @@ test: require_env build
|
||||||
-agentvm \
|
-agentvm \
|
||||||
-thd:"${TARGET_JAR}" \
|
-thd:"${TARGET_JAR}" \
|
||||||
-th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
|
-th:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
|
||||||
|
-thtimeout:0 \
|
||||||
-od:"${TARGET_JAR}" \
|
-od:"${TARGET_JAR}" \
|
||||||
-o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
|
-o:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
|
||||||
-w:"${RUN_DIR}/JTwork" \
|
-w:"${RUN_DIR}/JTwork" \
|
||||||
|
|
|
@ -164,7 +164,8 @@ public class ActionHelper {
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
stopwatch.start();
|
stopwatch.start();
|
||||||
|
|
||||||
log.printf("%s%n[%tF %<tT] %s%n%1$s%n", line, new Date(), pb.command());
|
log.printf("%s%n[%tF %<tT] %s timeout=%s%n%1$s%n", line, new Date(), pb.command(), params.timeout);
|
||||||
|
|
||||||
Process process;
|
Process process;
|
||||||
KillerTask killer;
|
KillerTask killer;
|
||||||
|
|
||||||
|
@ -178,22 +179,20 @@ public class ActionHelper {
|
||||||
out);
|
out);
|
||||||
try {
|
try {
|
||||||
result = new ExitCode(process.waitFor());
|
result = new ExitCode(process.waitFor());
|
||||||
killer.cancel();
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
log.println("WARNING: interrupted when waiting for the tool:%n");
|
||||||
if (!killer.cancel()) {
|
|
||||||
log.println(
|
|
||||||
"WARNING: interrupted when waiting for the tool:");
|
|
||||||
e.printStackTrace(log);
|
e.printStackTrace(log);
|
||||||
}
|
} finally {
|
||||||
|
killer.cancel();
|
||||||
}
|
}
|
||||||
if (killer.hasTimedOut()) {
|
if (killer.hasTimedOut()) {
|
||||||
log.printf(
|
log.printf(
|
||||||
"WARNING: tool timed out: killed process after %d ms%n",
|
"WARNING: tool timed out: killed process after %d ms%n",
|
||||||
TimeUnit.MILLISECONDS.toMicros(params.timeout));
|
params.timeout);
|
||||||
result = ExitCode.TIMED_OUT;
|
result = ExitCode.TIMED_OUT;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
log.printf("WARNING: caught IOException while running tool%n");
|
||||||
e.printStackTrace(log);
|
e.printStackTrace(log);
|
||||||
result = ExitCode.LAUNCH_ERROR;
|
result = ExitCode.LAUNCH_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +200,7 @@ public class ActionHelper {
|
||||||
stopwatch.stop();
|
stopwatch.stop();
|
||||||
log.printf("%s%n[%tF %<tT] exit code: %d time: %d ms%n%1$s%n",
|
log.printf("%s%n[%tF %<tT] exit code: %d time: %d ms%n%1$s%n",
|
||||||
line, new Date(), result.value,
|
line, new Date(), result.value,
|
||||||
TimeUnit.MILLISECONDS.toSeconds(stopwatch.getElapsedTimeNs()));
|
TimeUnit.NANOSECONDS.toMillis(stopwatch.getElapsedTimeNs()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ public class ActionHelper {
|
||||||
log.printf("WARNING: can't run jps : %s%n", e.getMessage());
|
log.printf("WARNING: can't run jps : %s%n", e.getMessage());
|
||||||
e.printStackTrace(log);
|
e.printStackTrace(log);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
log.printf("WARNING: interrupted%n");
|
||||||
e.printStackTrace(log);
|
e.printStackTrace(log);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -266,8 +265,7 @@ public class ActionHelper {
|
||||||
try {
|
try {
|
||||||
process.exitValue();
|
process.exitValue();
|
||||||
} catch (IllegalThreadStateException e) {
|
} catch (IllegalThreadStateException e) {
|
||||||
// !prepareProcess.isAlive()
|
process.destroyForcibly();
|
||||||
process.destroy();
|
|
||||||
timedOut = true;
|
timedOut = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,13 +299,17 @@ public class ActionHelper {
|
||||||
exitCode.value);
|
exitCode.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// sleep, if this is not the last iteration
|
||||||
|
if (i < n - 1) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(params.pause);
|
Thread.sleep(params.pause);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
sectionWriter.printf(
|
||||||
|
"WARNING: interrupted while sleeping between invocations");
|
||||||
e.printStackTrace(sectionWriter);
|
e.printStackTrace(sectionWriter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
run(section.getWriter(), section.getWriter(), process, params);
|
run(section.getWriter(), section.getWriter(), process, params);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue