test/java/rmi/testlibrary/ActivationLibrary.java

Print this page

        

@@ -38,47 +38,32 @@
 /**
  * Class of test utility/library methods related to Activatable
  * objects.
  */
 public class ActivationLibrary {
-    /** time safeDestroy should wait before failing on shutdown rmid */
-    private static final int SAFE_WAIT_TIME;
-    static {
-        int slopFactor = 1;
-        try {
-            slopFactor = Integer.valueOf(
-                TestLibrary.getExtraProperty("jcov.sleep.multiplier","1"));
-        } catch (NumberFormatException ignore) {}
-        SAFE_WAIT_TIME = 60000 * slopFactor;
-    }
-
-    private static final String SYSTEM_NAME =
-        ActivationSystem.class.getName();
-
     private static void mesg(Object mesg) {
         System.err.println("ACTIVATION_LIBRARY: " + mesg.toString());
     }
 
     /**
      * Deactivate an activated Activatable
      */
     public static void deactivate(Remote remote,
                                   ActivationID id) {
-        // We do as much as 50 deactivation trials, each separated by
-        // at least 100 milliseconds sleep time (max sleep time of 5 secs).
-        final long deactivateSleepTime = 100;
-        long stopTime = System.currentTimeMillis() + deactivateSleepTime * 50;
-        while (System.currentTimeMillis() < stopTime) {
+        final long POLLTIME_MS = 100L;
+        final long DEACTIVATE_TIME_MS = 30_000L;
+
+        long startTime = System.currentTimeMillis();
+        long deadline = TestLibrary.computeDeadline(startTime, DEACTIVATE_TIME_MS);
+
+        while (System.currentTimeMillis() < deadline) {
             try {
                 if (Activatable.inactive(id) == true) {
                     mesg("inactive successful");
                     return;
                 } else {
-                    mesg("inactive trial failed. Sleeping " +
-                         deactivateSleepTime +
-                         " milliseconds before next trial");
-                    Thread.sleep(deactivateSleepTime);
+                    Thread.sleep(POLLTIME_MS);
                 }
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 mesg("Thread interrupted while trying to deactivate activatable. Exiting deactivation");
                 return;

@@ -93,11 +78,12 @@
                 }
                 return;
             }
         }
 
-        mesg("unable to inactivate after several attempts");
+        mesg("unable to inactivate after " +
+            (System.currentTimeMillis() - startTime) + "ms.");
         mesg("unexporting object forcibly instead");
 
         try {
             Activatable.unexportObject(remote, true);
         } catch (NoSuchObjectException e) {