test/java/rmi/transport/pinLastArguments/PinLastArguments.java

Print this page

        

@@ -76,14 +76,19 @@
         } finally {
             UnicastRemoteObject.unexportObject(impl, true);
         }
         impl = null;
 
+        // Might require multiple calls to System.gc() for weak-references
+        // processing to be complete. If the weak-reference is not cleared as
+        // expected we will hang here until timed out by the test harness. 
+        while (true) {
         System.gc();
-
-        if (ref.get() != null) {
-            throw new Error("TEST FAILED: impl not garbage collected");
+            Thread.sleep(20);
+            if(ref.get() == null) {
+                break;
+            }
         }
 
         System.err.println("TEST PASSED");
     }
 }