Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues
Bug 770 - The complex data stored in DynAny can't be extracted correctly
Summary: The complex data stored in DynAny can't be extracted correctly
Status: RESOLVED INVALID
Alias: None
Product: JacORB
Classification: Unclassified
Component: DynAny (show other bugs)
Version: 2.3.0
Hardware: PC Windows 2000
: P2 normal
Assignee: Gerald Brose
URL:
Depends on:
Blocks:
 
Reported: 2007-04-26 07:31 CEST by Shi Lei
Modified: 2013-11-27 07:49 CET (History)
1 user (show)

See Also:


Attachments
Demo code and patch which reproduce this case (6.32 KB, application/octet-stream)
2007-04-26 07:40 CEST, Shi Lei
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shi Lei 2007-04-26 07:31:55 CEST
I made some tests using the demo (%JACORB_HOME%\demo\dynany)
and found if put a complex data (e.g. a DynStruct) in an 'Any' object
which be converted to a 'DynAny' object, then DynAnyFactoryImpl will can
not extract the actual value correctly.
The following is the sample code (refer to
"%JACORB_HOME%\demo\dynany\Client.java"):
......
Any any = orb.create_any();
any.insert_any(dyn_struct.to_any()); // dyn_struct is a DynStruct
instance, I omit how to create it, please see the demo...
DynAny dynany = dynFactory.create_dyn_any(any);
     
System.out.println("Passing a any..." + s.generic( dynany.to_any() ) );
......
and Server can't display the actual value from the Any pass to it.
(refer to "%JACORB_HOME%\demo\dynany\Server.java")
As a workaround, I changed DynAnyFactoryImpl (create_dyn_any method)
like:
===================================================================
public org.omg.DynamicAny.DynAny create_dyn_any( org.omg.CORBA.Any value
)
       throws InconsistentTypeCode
    {
       try
       {
           // Correction:
           // In case of objects forwarded in value member of Any the
TypeCode of inner object
           // has to be used for further processing (in other case it is
treated as TCKind._tk_any)
 
           if (value instanceof org.jacorb.orb.Any)
           {
               java.lang.Object obj =
((org.jacorb.orb.Any)value).value();
 
               if (obj instanceof org.jacorb.orb.Any)
               {
                   org.jacorb.orb.Any anyValue =
(org.jacorb.orb.Any)obj;
 
                   org.omg.DynamicAny.DynAny dynAny =
                      create_dyn_any_from_type_code(anyValue.type());
                   dynAny.from_any( anyValue );
                   return dynAny;
               }
           }
 
           // end of correction
 
          org.omg.DynamicAny.DynAny dynAny =
             create_dyn_any_from_type_code( value.type() );
          dynAny.from_any( value );
          return dynAny;
       }
.......
========================================================================
then the value can be extracted from Any and Server display the correct
content within Any.
 
I don't know whether it is a bug of JacORB2.3.0, if it is I wonder
whether my doing above is correct, and if the change will cause any
other side-effect?
Could anybody look into this issue and give me some clarification?
 
Thanks in advance,
Shi Lei
Comment 1 Shi Lei 2007-04-26 07:40:06 CEST
Created attachment 313 [details]
Demo code and patch which reproduce this case
Comment 2 Nick Cross 2013-11-27 07:49:08 CET
I've tried different ORBs and all have the same behaviour as JacORB and have read the spec and can't see anything that implies this should be done. For now therefore I am closing this ticket - if you have another interpretation please reopen.