8049194: com/sun/tools/attach/StartManagementAgent.java start failing after JDK-8048193
Reviewed-by: dfuchs, egahlin, olagneau
This commit is contained in:
parent
7f8815e010
commit
924b9f9fde
jdk/test
com/sun/jdi
javax/management/monitor
lib/testlibrary/jdk/testlibrary
@ -108,7 +108,7 @@ public class ExclusiveBind {
|
||||
"process1",
|
||||
process1,
|
||||
line -> line.equals("Listening for transport dt_socket at address: " + address),
|
||||
Math.round(5000 * Utils.TIMEOUT_FACTOR),
|
||||
Utils.adjustTimeout(5000),
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
||||
|
@ -213,6 +213,6 @@ public class StartStopTest {
|
||||
}
|
||||
|
||||
private static void doSleep(long ms) throws Exception {
|
||||
Thread.sleep(Math.round(ms * Utils.TIMEOUT_FACTOR));
|
||||
Thread.sleep(Utils.adjustTimeout(ms));
|
||||
}
|
||||
}
|
||||
|
@ -148,9 +148,7 @@ public class ProcessThread extends TestThread {
|
||||
*/
|
||||
@Override
|
||||
public void xrun() throws Throwable {
|
||||
this.process = ProcessTools.startProcess(
|
||||
name, processBuilder, waitfor, -1, TimeUnit.SECONDS
|
||||
);
|
||||
this.process = ProcessTools.startProcess(name, processBuilder, waitfor);
|
||||
// Release when process is started
|
||||
latch.countDown();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public final class ProcessTools {
|
||||
public static Process startProcess(String name,
|
||||
ProcessBuilder processBuilder)
|
||||
throws IOException {
|
||||
return startProcess(name, processBuilder, null);
|
||||
return startProcess(name, processBuilder, (Consumer)null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ public final class ProcessTools {
|
||||
* Used to determine the moment the target app is
|
||||
* properly warmed-up.
|
||||
* It can be null - in that case the warmup is skipped.
|
||||
* @param timeout The timeout for the warmup waiting
|
||||
* @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
|
||||
* @param unit The timeout {@linkplain TimeUnit}
|
||||
* @return Returns the initialized {@linkplain Process}
|
||||
* @throws IOException
|
||||
@ -156,15 +156,20 @@ public final class ProcessTools {
|
||||
};
|
||||
stdout.addPump(pump);
|
||||
stderr.addPump(pump);
|
||||
} else {
|
||||
latch.countDown();
|
||||
}
|
||||
Future<Void> stdoutTask = stdout.process();
|
||||
Future<Void> stderrTask = stderr.process();
|
||||
|
||||
try {
|
||||
if (timeout > -1) {
|
||||
long realTimeout = Math.round(timeout * Utils.TIMEOUT_FACTOR);
|
||||
if (!latch.await(realTimeout, unit)) {
|
||||
throw new TimeoutException();
|
||||
if (timeout == 0) {
|
||||
latch.await();
|
||||
} else {
|
||||
if (!latch.await(Utils.adjustTimeout(timeout), unit)) {
|
||||
throw new TimeoutException();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (TimeoutException | InterruptedException e) {
|
||||
@ -180,6 +185,31 @@ public final class ProcessTools {
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Starts a process from its builder.</p>
|
||||
* <span>The default redirects of STDOUT and STDERR are started</span>
|
||||
* <p>
|
||||
* It is possible to wait for the process to get to a warmed-up state
|
||||
* via {@linkplain Predicate} condition on the STDOUT
|
||||
* </p>
|
||||
* @param name The process name
|
||||
* @param processBuilder The process builder
|
||||
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT
|
||||
* Used to determine the moment the target app is
|
||||
* properly warmed-up.
|
||||
* It can be null - in that case the warmup is skipped.
|
||||
* @return Returns the initialized {@linkplain Process}
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
* @throws TimeoutException
|
||||
*/
|
||||
public static Process startProcess(String name,
|
||||
ProcessBuilder processBuilder,
|
||||
final Predicate<String> linePredicate)
|
||||
throws IOException, InterruptedException, TimeoutException {
|
||||
return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pumps stdout and stderr from running the process into a String.
|
||||
*
|
||||
|
@ -280,4 +280,13 @@ public final class Utils {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the provided timeout value for the TIMEOUT_FACTOR
|
||||
* @param tOut the timeout value to be adjusted
|
||||
* @return The timeout value adjusted for the value of "test.timeout.factor"
|
||||
* system property
|
||||
*/
|
||||
public static long adjustTimeout(long tOut) {
|
||||
return Math.round(tOut * Utils.TIMEOUT_FACTOR);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user