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

CDROutputStream throws ArrayIndexOutOfBoundsException for characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6u13
    • other-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The Java CORBA ORB can not handle data structures where a char type is written to the stream after a string type and the size of the string type was 0.

      For example:

      struct Broken
      {
      StandardString str;
      char ch;
      };

      If this object was returned from an interface, and the "str" member was an empty string, a SystemException would be thrown on the client side.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an IDL structure that contains a string member followed by a char member.

      Create a IDL interface that returns the structure.

      Invoke the interface from a Java application.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No errors should be encountered.
      ACTUAL -
      An exception and strack trace will be printed when invoking servant.foo().

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Aug 28, 2009 2:55:14 PM com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl convertThrowableToSystemException
      WARNING: "IOP00010202: (UNKNOWN) Unknown user exception thrown by the server"
      org.omg.CORBA.UNKNOWN: vmcid: SUN minor code: 202 completed: Maybe
      at com.sun.corba.se.impl.logging.ORBUtilSystemException.runtimeexception(ORBUtilSystemException.java:8365)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.convertThrowableToSystemException(CorbaMessageMediatorImpl.java:1918)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1868)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1821)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:258)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1680)
      at com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:155)
      at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:129)
      at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
      at _AStub.foo(_AStub.java:17)
      at test.main(test.java:36)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
      at com.sun.corba.se.impl.encoding.CodeSetConversion$JavaCTBConverter.convert(CodeSetConversion.java:188)
      at com.sun.corba.se.impl.encoding.CDROutputStream_1_0.write_char(CDROutputStream_1_0.java:312)
      at com.sun.corba.se.impl.encoding.CDROutputStream.write_char(CDROutputStream.java:120)
      at BrokenHelper.write(BrokenHelper.java:81)
      at APOA._invoke(APOA.java:37)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:637)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:189)
      ... 6 more
      org.omg.CORBA.UNKNOWN: ----------BEGIN server-side stack trace----------
      org.omg.CORBA.UNKNOWN: vmcid: SUN minor code: 202 completed: Maybe
      at com.sun.corba.se.impl.logging.ORBUtilSystemException.runtimeexception(ORBUtilSystemException.java:8365)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.convertThrowableToSystemException(CorbaMessageMediatorImpl.java:1918)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1868)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1821)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:258)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1680)
      at com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:155)
      at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:129)
      at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
      at _AStub.foo(_AStub.java:17)
      at test.main(test.java:36)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
      at com.sun.corba.se.impl.encoding.CodeSetConversion$JavaCTBConverter.convert(CodeSetConversion.java:188)
      at com.sun.corba.se.impl.encoding.CDROutputStream_1_0.write_char(CDROutputStream_1_0.java:312)
      at com.sun.corba.se.impl.encoding.CDROutputStream.write_char(CDROutputStream.java:120)
      at BrokenHelper.write(BrokenHelper.java:81)
      at APOA._invoke(APOA.java:37)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:637)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:189)
      ... 6 more

      ----------END server-side stack trace---------- vmcid: SUN minor code: 202 completed: Maybe
      org.omg.CORBA.UNKNOWN: ----------BEGIN server-side stack trace----------
      org.omg.CORBA.UNKNOWN: vmcid: SUN minor code: 202 completed: Maybe
      at com.sun.corba.se.impl.logging.ORBUtilSystemException.runtimeexception(ORBUtilSystemException.java:8365)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.convertThrowableToSystemException(CorbaMessageMediatorImpl.java:1918)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1868)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleThrowableDuringServerDispatch(CorbaMessageMediatorImpl.java:1821)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:258)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1680)
      at com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:155)
      at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:129)
      at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
      at _AStub.foo(_AStub.java:17)
      at test.main(test.java:36)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
      at com.sun.corba.se.impl.encoding.CodeSetConversion$JavaCTBConverter.convert(CodeSetConversion.java:188)
      at com.sun.corba.se.impl.encoding.CDROutputStream_1_0.write_char(CDROutputStream_1_0.java:312)
      at com.sun.corba.se.impl.encoding.CDROutputStream.write_char(CDROutputStream.java:120)
      at BrokenHelper.write(BrokenHelper.java:81)
      at APOA._invoke(APOA.java:37)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:637)
      at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:189)
      ... 6 more

      ----------END server-side stack trace---------- vmcid: SUN minor code: 202 completed: Maybe
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:902)
      at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:99)
      at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(CorbaMessageMediatorImpl.java:572)
      at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:430)
      at com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:189)
      at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:129)
      at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
      at _AStub.foo(_AStub.java:17)
      at test.main(test.java:36)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      1) Create an IDL file called "test.idl" and copy the following into it

      typedef string<100> StandardString;

      struct Broken
      {
      StandardString str;
      char ch;
      };

      interface A
      {
      Broken foo();
      };

      2) Compile the idl file using

      %JAVA_HOME%\bin\idlj -emitAll -fallTie test.idl

      3) Create a test program that uses the interface and structures from the IDL file. For example:



      import org.omg.PortableServer.POA;
      import org.omg.PortableServer.POAManager;
      import org.omg.PortableServer.POAHelper;


      public class test
      {
          private static final String ROOT_POA = "RootPOA";


      public static void main( String[] argv )
      {
      try
      {
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(argv, null);

      org.omg.CORBA.Object poaObj =
      orb.resolve_initial_references(ROOT_POA);

      POA poa = POAHelper.narrow(poaObj);

      POAManager poaManager = poa.the_POAManager();
      poaManager.activate();

      AImpl impl = new AImpl();
      byte[] id = poa.activate_object(impl);


      A myRef = AHelper.narrow(poa.id_to_reference(id));

      String ior = orb.object_to_string( myRef);
      A servant = (A)orb.string_to_object( ior );

      Broken b = servant.foo();
      }
      catch( Exception e )
      {
      System.out.println( e );
      e.printStackTrace();
      }
      }
      }


      class AImpl extends APOA
      {

      public Broken foo()
      {
      Broken rtn = new Broken();
      rtn.str = "";
      rtn.ch = 'a';

      return rtn;
      }

      }

      4) Compile your test application along with the IDL stubs and skeletons.

      5) Execute the test application.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change all char types to octet types in IDL files.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: