[ http://jira.jboss.com/jira/browse/JBAS-1506?page=history ]

Ivelin Ivanov reassigned JBAS-1506:
-----------------------------------

    Assign To: Ivelin Ivanov  (was: Dimitris Andreadis)

> CDROutputStream.create_input_stream is wrong when there are deferred writes
> ---------------------------------------------------------------------------
>
>          Key: JBAS-1506
>          URL: http://jira.jboss.com/jira/browse/JBAS-1506
>      Project: JBoss Application Server
>         Type: Patch
>   Components: IIOP service
>     Versions: JBossAS-4.0.1 Final,  JBossAS-3.2.7 Final
>  Environment: This related to a jacorb bug, see: 
> http://www.jacorb.org/cgi-bin/bugzilla/show_bug.cgi?id=532
>     Reporter: Dimitris Andreadis
>     Assignee: Ivelin Ivanov
>      Fix For: JBossAS-5.0 Alpha, JBossAS-4.0.2 Final

>
>
> An exception is thrown when trying to insert a byte[] larger than 4000 bytes 
> into any any:
> package test;
> import java.util.Properties;
> import org.omg.CORBA.ORB;
> import org.omg.CORBA.Any;
> import org.omg.CORBA.OctetSeqHelper;
> public class Test
> {
>    public static final void main(String[] args)
>    {
>       System.out.println("*** Starting test ***");
>       
>       try
>       {
>          Properties props = new Properties();
>          props.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
>          props.put("org.omg.CORBA.ORBSingletonClass", 
> "org.jacorb.orb.ORBSingleton");
>          
>          ORB orb = ORB.init(args, props);
>       
>          byte[] bytes = new byte[4001];
>          Any any = orb.create_any();
>          OctetSeqHelper.insert(any, bytes);         
>       }
>       catch (Exception e)
>       {
>          e.printStackTrace();
>       }
>    }
> }
> ===================================================
>      [java] *** Starting test ***
>      [java] [ jacorb.home unset! Will use '.' ]
>      [java] [ File .\jacorb.properties for configuration jacorb not found ]
>      [java] java.lang.ArrayIndexOutOfBoundsException
>      [java]     at java.lang.System.arraycopy(Native Method)
>      [java]     at org.jacorb.orb.CDROutputStream.create_input_stream(Unknown 
> So
> urce)
>      [java]     at org.omg.CORBA.OctetSeqHelper.insert(OctetSeqHelper.java:41)
>      [java]     at test.Test.main(Test.java:24)
> =======================================================
> With a byte[] of size 4000 or less, it works!
> I've noticed that the exception actually originates from the Helper class 
> that comes from Sun's JDK:
> ...
> public abstract class OctetSeqHelper
> {
>     private static String  _id = "IDL:omg.org/CORBA/OctetSeq:1.0";
>     public static void insert (org.omg.CORBA.Any a, byte[] that)
>     {
>       org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
>       a.type (type ());
>       write (out, that);
>       a.read_value (out.create_input_stream (), type ());
>     }
> The same class from the jacorb distribution does not perform that final 
> "a.read_value(...)" line that causes the exception:
>       public static void insert (org.omg.CORBA.Any any, byte[] s)
>       {
>               any.type (type ());
>               write (any.create_output_stream (), s);
>       }
>       public static void write (final org.omg.CORBA.portable.OutputStream 
> _out, byte[] _s)
>       {
>               
>               _out.write_long(_s.length);
>               _out.write_octet_array(_s,0,_s.length);
>       }
> Also, if you look into jacorb's CDROutputStream, there is somewhere a 
> hardcoded 4000 limit:
>     public final void write_octet_array( final byte[] value,
>                                          final int offset,
>                                          final int length)
>     {
>         if( value != null )
>         {
>             if( length > 4000 )
>             {
>                 deferredArrayQueue.add( new DeferredWriteFrame( index, 
> offset, length, value ));
>                 index += length;
>                 deferred_writes += length;
>             }
>             else
>             {
>                 check(length);
>                 System.arraycopy(value,offset,buffer,pos,length);
>                 index += length;
>                 pos += length;
>             }
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.jboss.com/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-Development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to