test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java

Print this page




  65         }
  66     }
  67 
  68     public void declareStillAlive() {
  69         synchronized (lock) {
  70             stillAlive = true;
  71             lock.notifyAll();
  72         }
  73     }
  74 
  75     public static void main(String[] args) {
  76 
  77         System.err.println("\nRegression test for bug 4308492\n");
  78 
  79         KeepAliveDuringCall obj = new KeepAliveDuringCall();
  80 
  81         try {
  82             UnicastRemoteObject.exportObject(obj);
  83             System.err.println("exported shutdown monitor");
  84 
  85             Registry localRegistry =
  86                 LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT);
  87             System.err.println("created local registry");
  88 
  89             localRegistry.bind(BINDING, obj);
  90             System.err.println("bound shutdown monitor in local registry");
  91 
  92             System.err.println("starting remote ShutdownImpl VM...");
  93             (new JavaVM("ShutdownImpl")).start();


  94 
  95             Shutdown s;
  96             synchronized (obj.lock) {
  97                 System.err.println(
  98                     "waiting for submission of object to shutdown...");
  99                 while ((s = obj.shutdown) == null) {
 100                     obj.lock.wait(TIMEOUT);
 101                 }
 102                 if (s == null) {
 103                     throw new RuntimeException(
 104                         "TEST FAILED: timeout waiting for shutdown object " +
 105                         "to make initial contact");
 106                 }
 107                 System.err.println("shutdown object submitted: " + s);
 108             }
 109 
 110             try {
 111                 s.shutdown();
 112             } catch (RemoteException e) {
 113                 throw new RuntimeException(




  65         }
  66     }
  67 
  68     public void declareStillAlive() {
  69         synchronized (lock) {
  70             stillAlive = true;
  71             lock.notifyAll();
  72         }
  73     }
  74 
  75     public static void main(String[] args) {
  76 
  77         System.err.println("\nRegression test for bug 4308492\n");
  78 
  79         KeepAliveDuringCall obj = new KeepAliveDuringCall();
  80 
  81         try {
  82             UnicastRemoteObject.exportObject(obj);
  83             System.err.println("exported shutdown monitor");
  84 
  85             Registry localRegistry = TestLibrary.createRegistryOnUnusedPort();
  86             int registryPort = TestLibrary.getRegistryPort(localRegistry);
  87             System.err.println("created local registry");
  88 
  89             localRegistry.bind(BINDING, obj);
  90             System.err.println("bound shutdown monitor in local registry");
  91 
  92             System.err.println("starting remote ShutdownImpl VM...");
  93             (new JavaVM("ShutdownImpl",
  94                         "-Drmi.registry.port=" +
  95                         registryPort, "")).start();
  96 
  97             Shutdown s;
  98             synchronized (obj.lock) {
  99                 System.err.println(
 100                     "waiting for submission of object to shutdown...");
 101                 while ((s = obj.shutdown) == null) {
 102                     obj.lock.wait(TIMEOUT);
 103                 }
 104                 if (s == null) {
 105                     throw new RuntimeException(
 106                         "TEST FAILED: timeout waiting for shutdown object " +
 107                         "to make initial contact");
 108                 }
 109                 System.err.println("shutdown object submitted: " + s);
 110             }
 111 
 112             try {
 113                 s.shutdown();
 114             } catch (RemoteException e) {
 115                 throw new RuntimeException(