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

poa operation in etherealize() fails

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 that POA.destroy() with etherealize param true
      invokes
             etherealize method and operation on the poa inside the
      etherealize
           method should raise OBJECT_NOT_EXIST exception.(The apparent
           destruction of poa occurs before any calls to etherealize are made)

      Expected Result : Operation on POA inside the etherealize method raises

           OBJECT_NOT_EXIST exception.

      Result Obtained : Operation on POA inside the etherealize method does
      not
           raise OBJECT_NOT_EXIST exception.


      How to reproduce the bug.
      -------------------------
      idl file
      --------

      module destroybug004 {
       interface Hello {
        string sayHello();
       };

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

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

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

      import destroybug004.*;
      import org.omg.PortableServer.POA;
      import org.omg.PortableServer._ServantActivatorImplBase;
      import org.omg.CORBA.Policy;
      import org.omg.PortableServer.RequestProcessingPolicyValue;
      import org.omg.CORBA.ORB;
      import org.omg.CosNaming.NamingContext;
      import org.omg.CosNaming.NameComponent;
      import org.omg.CosNaming.NamingContextHelper;
      import org.omg.PortableServer.Servant;

      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);

         // creating corba object reference for PoaOperationServant
         org.omg.CORBA.Object objref2 = rootPoa.servant_to_reference(poaops);

         // Creating poa1
         System.out.println("Creating Poa1");
         Policy policy[] = new Policy[1];
         policy[0] =
      rootPoa.create_request_processing_policy(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);

         POA poa1 = rootPoa.create_POA("Poa1",null,policy);
         poa1.the_POAManager().activate();

         // set servant manger for poa1
         poa1.set_servant_manager(new ServantActivatorImpl());

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

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

         // creating corba object reference for HelloServant
         org.omg.CORBA.Object objref = poa1.servant_to_reference(serv1);

         System.out.println("Resolving Name Service");
                  org.omg.CORBA.Object obj =
      orb.resolve_initial_references("NameService");
                  NamingContext namingContext =
      NamingContextHelper.narrow(obj);
                  NameComponent nameComponent1 = new
      NameComponent("HelloServant", "");
                  NameComponent path1[] = { nameComponent1 };
                  namingContext.rebind(path1, objref);

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

         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

      class ServantActivatorImpl extends _ServantActivatorImplBase {

       public Servant incarnate(byte oid[],POA adapter)
         throws org.omg.PortableServer.ForwardRequest {

        Servant servant=null;

        try {
         servant=new HelloImpl();
        }
        catch(Exception ex) {
         System.out.println( "Unexpected Exception "+ex.toString());
        }
        return servant;

       } //incarnate

       public void etherealize(byte oid[], POA adapter, Servant serv,
         boolean cleanup_in_progress, boolean remaining_activations) {

          boolean objNotExcep = false;
          System.out.println("Inside etherealize method call ");
          PoaOperationImpl.etherealizeCalled=true;
          System.out.println("Invoking id_to_servant operation on POA and "
              + " expected to throw "
              + "OBJECT_NOT_EXIST exception");
          try {
           adapter.id_to_servant(oid);
          }
          catch(org.omg.CORBA.OBJECT_NOT_EXIST ex) {
           System.out.println("Operation on POA in the etherealize method"
             + " sucessfully throwed OBJECT_NOT_EXIST exception");
           objNotExcep = true;
          }
          catch(Exception ex) {
           System.out.println( "Unexpected Exception "+ex.toString());
          }
          if (!objNotExcep) {
           System.out.println("Operation on POA in the etherealize method
      failed to"+
            " throw OBJECT_NOT_EXIST exception");
          }
          return;
       } // etherealize

      } // class ServantActivatorImpl

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

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

      import destroybug004.*;
      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 nameComponent = new NameComponent("OperationServant",
      "");
         NameComponent path[] = { nameComponent };
         System.out.println("Resolving PoaOperation Object");
         poaOp = PoaOperationHelper.narrow(namingContext.resolve(path));
         System.out.println("Calling DestroyPOA");
         poaOp.destroyPOA();

        }
        catch (Exception ex){
         System.out.println("Unexpected Exception " + ex.toString());
        }
        System.out.println("Calling Shutdown");
        poaOp.shutdown();

       } // main()

      } // class DestroyClient

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

      PoaOperationImpl.java
      ---------------------

      import destroybug004.*;
      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;
       static boolean etherealizeCalled = false;

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

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

       public void destroyPOA() {
        try {
         System.out.println("PoaOperation : destroyPOA() called");

         org.omg.PortableServer.Current cur =
      (org.omg.PortableServer.Current)orb.resolve_initial_references("POACurrent");

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

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

         // Calling Destroy on poa1
         System.out.println("Calling Destroy on poa1 with wait_for_completion
      param true "
             + "and etherealize param true");
         poa1.destroy(true,true);

        }
        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()

      } // class PoaOperationImpl


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

      HelloImpl.java
      --------------

      import destroybug004.*;

      public class HelloImpl extends _HelloImplBase {

       public String sayHello() {
        return "Hello";
       }

      } //class HelloImpl

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

      Makefile
      --------
      #-------------------------------------------------------------------------------

      #Make changes to the makefile as per the local environment
      #Start the ORB demon
      #make all
      #make runserver
      #make runclient
      #-------------------------------------------------------------------------------

      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 destroybug004\*.*

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


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

            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: