8066835: TEST_BUG: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java fails
authorsmarks
Mon, 08 Dec 2014 14:32:31 -0800
changeset 27943 4ed49775c237
parent 27942 b43cb0ec4975
child 27944 c6d5edd39016
8066835: TEST_BUG: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java fails Reviewed-by: lancea
jdk/test/java/rmi/testlibrary/JavaVM.java
jdk/test/java/rmi/testlibrary/RMID.java
jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java
--- 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;