8066835: TEST_BUG: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java fails
Reviewed-by: lancea
--- a/jdk/test/java/rmi/testlibrary/JavaVM.java Mon Dec 08 11:54:17 2014 -0800
+++ b/jdk/test/java/rmi/testlibrary/JavaVM.java Mon Dec 08 14:32:31 2014 -0800
@@ -194,7 +194,7 @@
throws InterruptedException, TimeoutException {
if (vm == null)
throw new IllegalStateException("can't wait for JavaVM that isn't running");
- long deadline = System.currentTimeMillis() + timeout;
+ long deadline = computeDeadline(System.currentTimeMillis(), timeout);
while (true) {
try {
@@ -218,4 +218,21 @@
start();
return waitFor();
}
+
+ /**
+ * Computes a deadline from a timestamp and a timeout value.
+ * Maximum timeout (before multipliers are applied) is one hour.
+ */
+ public static long computeDeadline(long timestamp, long timeout) {
+ final long MAX_TIMEOUT_MS = 3_600_000L;
+
+ if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
+ throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
+ }
+
+ // TODO apply test.timeout.factor (and possibly jcov.sleep.multiplier)
+ // here instead of upstream
+
+ return timestamp + timeout;
+ }
}
--- a/jdk/test/java/rmi/testlibrary/RMID.java Mon Dec 08 11:54:17 2014 -0800
+++ b/jdk/test/java/rmi/testlibrary/RMID.java Mon Dec 08 14:32:31 2014 -0800
@@ -257,7 +257,7 @@
waitTime = waitTime * slopFactor;
long startTime = System.currentTimeMillis();
- long deadline = startTime + waitTime;
+ long deadline = computeDeadline(startTime, waitTime);
while (true) {
try {
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Mon Dec 08 11:54:17 2014 -0800
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Mon Dec 08 14:32:31 2014 -0800
@@ -38,7 +38,7 @@
public class RMIConnector_NPETest {
public static void main(String argv[]) throws Exception {
RMID rmid = RMID.createRMID();
- rmid.start(Long.MAX_VALUE);
+ rmid.start();
int rmidPort = rmid.getPort();
Exception failureCause = null;
RMIConnector agent = null;