Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4204653

poa.destroy with WAIT_FOR_COMPLETION

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.2.0
    • other-libs
    • None
    • beta
    • x86
    • windows_nt
    • Verified



      Name: rrC76497 Date: 01/21/99


      Test Environment: JDK1.1.6, Win NT 4.0

      Purpose : To verify POA.destroy() with wait_for_Completion false
      returns after
           destroying the POA, without waiting for active request to complete.

      Expected Result : Destroy operation returns immedietely

      Result Obtained : Destroy operation does not return immedietly and
      instead waits
           indefinitely.


      How to reproduce the bug.
      -------------------------

      idl file
      --------

      module destroybug003 {
       interface Hello {
        oneway void activeRequest();
       };

       interface PoaOperation {
        string display();
        void destroyPOA();
        oneway void shutdown();
       };
      };

      --------------------------------------------------------------------------------

      DestroyServer.java
      ------------------

      import destroybug003.*;
      import org.omg.PortableServer.POA;
      import org.omg.PortableServer._AdapterActivatorImplBase;
      import org.omg.CORBA.Policy;
      import org.omg.CORBA.ORB;
      import org.omg.CosNaming.NamingContext;
      import org.omg.CosNaming.NameComponent;
      import org.omg.CosNaming.NamingContextHelper;


      public class DestroyServer {

       public static void main(String args[]) {

        java.util.Properties p = new java.util.Properties();
        p.put("org.omg.CORBA.ORBClass","com.sun.PortableServer.POAORB");

           HelloImpl serv1=null;
        PoaOperationImpl poaops=null;
        POA rootPoa=null;

        try {
         // initialising the orb of this instance
         System.out.println("Initialising ORB");
         ORB orb = ORB.init(args,p);

         // getting reference to the default rootPOA
         System.out.println("Getting Root POA");
         rootPoa = (POA)orb.resolve_initial_references("RootPOA");

         //activate the POAManager
         rootPoa.the_POAManager().activate();

         // Creating PoaOperationServant
         System.out.println("Creating PoaOperations Servant");
         poaops = new PoaOperationImpl(orb);

         // Activating PoaOperationServant with rootPoa
         rootPoa.activate_object(poaops);

         // create Object reference for PoaOperationsImpl
         org.omg.CORBA.Object objRef1 = rootPoa.servant_to_reference(poaops);

         // Creating poa1
         System.out.println("Creating Poa1");
         POA poa1 = rootPoa.create_POA("Poa1",null,null);
         poa1.the_POAManager().activate();


         // Creating HelloServant
         System.out.println("Creating Hello Servant");
         serv1 = new HelloImpl();

         // Activating HelloServant with poa1
         poa1.activate_object(serv1);

         // create Object reference for helloImpl
         org.omg.CORBA.Object objRef2 = poa1.servant_to_reference(serv1);

         // Obtains the root Naming Context
                  org.omg.CORBA.Object obj =
      orb.resolve_initial_references("NameService");
                  NamingContext namingContext =
      NamingContextHelper.narrow(obj);

         // Binding the Name and servant with Root naming context
                  NameComponent nameComponent1 = new
      NameComponent("HelloServant", "");
                  NameComponent path1[] = { nameComponent1 };
                  namingContext.rebind(path1, objRef2);

                  NameComponent nameComponent2 = new
      NameComponent("OperationServant", "");
                  NameComponent path2[] = { nameComponent2 };
                  namingContext.rebind(path2, objRef1);

         orb.run();
        }
        catch(org.omg.CORBA.SystemException ex) {
         System.out.println(" Unexpected exception "+ex.toString());
         return;
        }
        catch (Exception e) {
         System.out.println("Unexpected Exception" + e.toString() + "\n");
         return;
        }

       } // main

      } // class DestroyServer

      -------------------------------------------------------------------------------

      DestroyClient.java
      ------------------

      import destroybug003.*;
      import org.omg.CORBA.ORB;
      import org.omg.CosNaming.NameComponent;
      import org.omg.CosNaming.NamingContext;
      import org.omg.CosNaming.NamingContextHelper;

      public class DestroyClient {

       public static void main(String args[]) {

        java.util.Properties p = new java.util.Properties();
        p.put("org.omg.CORBA.ORBClass","com.sun.PortableServer.POAORB");
        System.out.println("Initialising ORB");
        ORB orb = ORB.init(args,p);
        PoaOperation poaOp = null;

        try{
         org.omg.CORBA.Object obj =
      orb.resolve_initial_references("NameService");
         NamingContext namingContext = NamingContextHelper.narrow(obj);
         NameComponent nameComponent1 = new NameComponent("HelloServant", "");

         NameComponent path1[] = { nameComponent1 };
         Hello hello = HelloHelper.narrow(namingContext.resolve(path1));
         System.out.println("Resolving Hello Object");

         NameComponent nameComponent2 = new NameComponent("OperationServant",
      "");
         NameComponent path2[] = { nameComponent2 };
         System.out.println("Resolving PoaOperation Object");
         poaOp = PoaOperationHelper.narrow(namingContext.resolve(path2));

         System.out.println("Calling activeRequest");
         hello.activeRequest();

         System.out.println("Calling DestroyPOA");
         poaOp.destroyPOA();

        } //try
        catch (Exception ex){
         System.out.println("Unexpected Exception " + ex.toString());
        } //catch

        System.out.println("Calling Shutdown");
        poaOp.shutdown();
       } // main

      } // class DestroyClient

      --------------------------------------------------------------------------------

      PoaOperationsImpl.java
      ----------------------

      import destroybug003.*;
      import org.omg.PortableServer.POA;
      import org.omg.CORBA.ORB;


      class PoaOperationImpl extends _PoaOperationImplBase {
       private ORB orb;
       static java.lang.Object DestroyLock = new java.lang.Object();
       static boolean WaitState=false;

       public PoaOperationImpl(ORB orb) {
        System.out.println("Constructing PoaOperationImpl");
        this.orb = orb;
       } // PoaOperationImpl

       public String display() {
        return "Hello";
       } // display()

       /* Destroys poa1 */
       public void destroyPOA() {
        try {
         System.out.println("Inside destroyPOA");
         org.omg.PortableServer.Current cur =
      (org.omg.PortableServer.Current)orb.resolve_initial_references("POACurrent");

         POA root = cur.get_POA(); // returns Poa1 which is a child of rootpoa


         // Finding Poa1 for destroy operation from the rootpoa
         POA poa1 = root.find_POA("Poa1",false);

         // Calling Destroy on poa1
         System.out.println("Calling Destroy on poa2 with WAIT_FOR_COMPLETION
      false");
         poa1.destroy(false,false);

         if (!WaitState)
         {
          System.out.println("Destroy returned immedietly before Completing
      Active request");
         }
         else {
          System.out.println("Destroy failed to return immedietly when "+
           "active request are there and WAIT_FORM_COMPLETION is false");
         }

        }
        catch(Exception ex) {
         ex.printStackTrace();
        }

        finally {
         try {
          synchronized(DestroyLock) {
           DestroyLock.notify();
          }
         }
         catch(Exception ex) {
          System.out.println("Unexpected Exception" + ex.toString());
         }
        }

       } // destroyPOA()

       public void shutdown() {
        System.out.println("Shutdown call for ORB");
        orb.shutdown(false);
       } // shutdown()

      } // PoaOperationImpl

      -------------------------------------------------------------------------------

      HelloImpl
      ---------

      import destroybug003.*;

      public class HelloImpl extends _HelloImplBase {

       // activeRequest method is made to wait until it is notified

       public void activeRequest() {
        System.out.println("activeRequest() started");
        try {
         synchronized(PoaOperationImpl.DestroyLock) {
          PoaOperationImpl.DestroyLock.wait();
          PoaOperationImpl.WaitState=true;
         }
        }
        catch(Exception ex) {
          System.out.println("Unexpected Exception" + ex.toString());
        }
        System.out.println("activeRequest() completed");
       }
      }
      --------------------------------------------------------------------------------

      Makefile
      --------

      IDLX_HOME=d:\javaidlx-2.1
      IDLTOJAVA=$(IDLX_HOME)\bin\win32\idltojava

      JAVAHOME=d:\jdk1.1.6
      JAVAC=$(JAVAHOME)\bin\javac
      JAVA=$(JAVAHOME)\bin\java
      CLASSPATH = .;$(JAVAHOME)\lib\classes.zip;$(IDLX_HOME)\lib\classes.zip;

      all: idl server client

      server: DestroyServer.java HelloImpl.java PoaOperationImpl.java
       $(JAVAC) -classpath $(CLASSPATH) DestroyServer.java HelloImpl.java
      PoaOperationImpl.java

      client: DestroyClient.java
       $(JAVAC) -classpath $(CLASSPATH) DestroyClient.java

      idl: hello.idl
       $(IDLTOJAVA) -fno-cpp -j . hello.idl

      runserver: DestroyServer.class
       $(JAVA) -classpath $(CLASSPATH) DestroyServer -ORBInitialHost localhost
      -ORBInitialPort 900

      runclient: DestroyClient.class
       $(JAVA) -classpath $(CLASSPATH) DestroyClient -ORBInitialHost localhost
      -ORBInitialPort 900

      clean:
       del *.class
       del destroybug003\*.*

      --------------------------------------------------------------------------------


      ======================================================================

            ajindalsunw Anita Jindal (Inactive)
            rramsunw Ranganathan Ram (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: