test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -30,10 +30,11 @@
  * @library ../../testlibrary
  * @build DGCDeadLock
  * @build Test
  * @build TestImpl
  * @build TestImpl_Stub
+ * @build TestLibrary
  * @run main/othervm/policy=security.policy/timeout=360 DGCDeadLock
  */
 
 /* This test attempts to cause a deadlock between the rmi leaseChecker
  * thread and a thread that is servicing a dgc clean call. Before the

@@ -51,11 +52,11 @@
 
 import java.rmi.*;
 import java.io.*;
 
 public class DGCDeadLock implements Runnable {
-
+    private static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort();
     final static public int HOLD_TARGET_TIME = 25000;
     public static int TEST_FAIL_TIME = HOLD_TARGET_TIME + 30000;
     public static boolean finished = false;
     static DGCDeadLock test = new DGCDeadLock();
 

@@ -73,11 +74,13 @@
         try {
             String options = " -Djava.security.policy=" +
                 TestParams.defaultPolicy +
                 " -Djava.rmi.dgc.leaseValue=500000" +
                 "  -Dsun.rmi.dgc.checkInterval=" +
-                (HOLD_TARGET_TIME - 5000) + "";
+                (HOLD_TARGET_TIME - 5000) +
+                "   -Drmi.registry.port=" + REGISTRY_PORT +
+                "" ;
 
             testImplVM = new JavaVM("TestImpl", options, "");
             testImplVM.start();
 
             synchronized (test) {

@@ -110,11 +113,11 @@
             // give the test remote object time to initialize.
             Thread.currentThread().sleep(8000);
 
             // create a test client
             Test foo = (Test) Naming.lookup("rmi://:" +
-                                            TestLibrary.REGISTRY_PORT +
+                                            REGISTRY_PORT +
                                             "/Foo");
             echo = foo.echo("Hello world");
             System.err.println("Test object created.");
 
             /* give TestImpl time to lock the target in the

@@ -129,11 +132,11 @@
             Runtime.getRuntime().gc();
             Runtime.getRuntime().runFinalization();
 
             //import "Bar"
             Test bar = (Test) Naming.lookup("rmi://:" +
-                                            TestLibrary.REGISTRY_PORT +
+                                            REGISTRY_PORT +
                                             "/Bar");
 
             /* infinite loop to show the liveness of Client,
              * if we have deadlock remote call will not return
              */