Bug 933 - Can't pass IOP::ServiceContext context_data to IOP::Codec::decode
Summary: Can't pass IOP::ServiceContext context_data to IOP::Codec::decode
Status: RESOLVED FIXED
Alias: None
Product: TAO
Classification: Unclassified
Component: Portable Interceptors (show other bugs)
Version: 1.1.16
Hardware: x86 Windows NT
: P3 normal
Assignee: DOC Center Support List (internal)
URL:
: 932 934 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-05-29 20:52 CDT by Greg Hall
Modified: 2007-04-18 08:59 CDT (History)
0 users

See Also:


Attachments
Complete bug description (previously ommitted) (1.38 KB, text/plain)
2001-05-29 21:07 CDT, Greg Hall
Details
codec example (2.67 KB, application/octet-stream)
2002-01-18 10:44 CST, Ruwanganie Gunatilleke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Hall 2001-05-29 20:52:37 CDT
With the specified configuration, code similar to the following:

   IOP::ServiceContext_var context = ... // get context
Comment 1 Greg Hall 2001-05-29 21:07:27 CDT
Created attachment 65 [details]
Complete bug description (previously ommitted)
Comment 2 Ossama Othman 2001-05-29 21:39:47 CDT
*** Bug 932 has been marked as a duplicate of this bug. ***
Comment 3 Ossama Othman 2001-05-29 21:40:21 CDT
*** Bug 934 has been marked as a duplicate of this bug. ***
Comment 4 Ossama Othman 2001-05-29 21:56:19 CDT
Below are the contents of Greg's attachment.  It's easier to have them 
available in the bug comments.  Thanks for tracking this down Greg!
-------------------------------------------------------------

I accidently sent the bug in an incomplete form, here's the complete 
description:

With the specified configuration, code similar to the following

  IOP::ServiceContext_var context = ... // get a service context
  IOP::Codec_var codec = ... // get a codec

  Any_var ctxVal = codec->decode(context->context_data);


produces a compile-time error on MSVC similar to:

error C2664: 'decode' cannot convert parameter 1 from 'class 
IOP::ServiceContext::_tao_seq_Octet' to 'const class CORBA_OctetSeq &'

due to the fact that the PIDL argument type for the decode operation is mapped 
differently from IOP::ServiceContext context_data member:

local interface Codec {
  ...
  any decode(in CORBA::OctetSeq) ...
  ...
};

and

struct ServiceContext {
  ...
  sequence<octet> context_data;
};

The workaround is to construct a temporary CORBA::OctetSeq type from the 
ServiceContext member. e.g.

  CORBA::OctetSeq tmp(
                    context->context_data.length();
                    context->context_data.length();
                    context->context_data.get_buffer();
                    0);

and pass it as the argument.

I'm not totally sure this is a bug as such, but it would be handy to able to 
have the CORBA::OctetSeq be used interchangeably with the anonymous Octet 
sequence type (especially since the OctetSeq is just a typedef of the anonymous 
type).
  

Comment 5 Irfan Pyarali 2001-06-13 14:46:27 CDT
Ossama, do you want to accept this bug?
Comment 6 Ossama Othman 2001-06-13 14:58:54 CDT
I'm reluctant to do so because this bug is not specific to Portable
Interceptors.
Comment 7 Ruwanganie Gunatilleke 2002-01-12 14:45:30 CST
Hi,
I also encountered this problem while writing an example for Portable 
Interceptors and used the same workaround. But when I try to decode this 
CORBA::OctetSeq, I get an exception. Since I couldn't figure out why that is 
happenning I wrote another example and it is like this:
In the servant class I have a method called send_message() which takes in a 
reference to a CORBA::OctetSeq

  virtual void send_message (const CORBA::OctetSeq & user_name)
    ACE_THROW_SPEC ((CORBA::SystemException));

and in the implementation for this method what I try to do is decode it:

      CORBA::Any_var user_name_as_any;
      user_name_as_any = codec->decode(user_name);

I was able to get this to build but when I try to run it I get a 
IDL:omg.org/IOP/Codec/FormatMismatch:1.0 exception.

Hope someone can give an idea to resolve this.

Thanks
Ru
Comment 8 Ossama Othman 2002-01-12 15:44:26 CST
We're going to need more information than that.  How did you encode the octet 
sequence?  Can you please provide a more complete example?
Comment 9 Ruwanganie Gunatilleke 2002-01-18 10:44:05 CST
Created attachment 103 [details]
codec example
Comment 10 Ruwanganie Gunatilleke 2002-01-18 10:49:51 CST
I added the complete example as an attachment (id=103). To build this example I 
used ACE version 1.2 and TAO version 1.2.
Comment 11 Johnny Willemsen 2007-03-27 09:00:53 CDT
pidl interface is changed long time ago, regression was infact broken

Tue Mar 27 13:56:40 UTC 2007  Johnny Willemsen  <jwillemsen@remedy.nl>

        * tests/Bug_933_Regression/*:
          New regression for bug 933. TAO didn't had a bug, the regression
          posted by the reporter had several. Fixed the regression and
          adding it now to svn. Thanks to Ruwanganie Gunatilleke
          <ru at ociweb dot com> for making the regression