Discussion:
Incorrect reply_status? - [ receive_exception() ]
Ricardo Cosme
2010-06-14 22:46:55 UTC
Permalink
Hi,

When I invoke a method that gives me an IDL:omg.org/CORBA/COMM_FAILURE:1.0,
my receive_exception() implementation receives a ri->reply_status() with
an USER_EXCEPTION value, but COMM_FAILURE is a SYSTEM_EXCEPTION.

I noticed that receive_exception_ip(), in pi_impl.cc:2245, doesn't use
reply_status
argument. It defines the _reply_status in line 2254 with an USER_EXCEPTION:

//pi_impl.cc
2254: cri->reply_status(PortableInterceptor::USER_EXCEPTION);

Shouldn't this line be:

cri->reply_status(reply_status);

I'm using Mico 2.3.13.

My demo:

#include <CORBA.h>

using namespace std;
using namespace PortableInterceptor;

class ClientInterceptor : public ClientRequestInterceptor {
private:
IOP::Codec_ptr cdr_codec;
public:
ClientInterceptor(IOP::Codec_ptr pcdr_codec) {}

~ClientInterceptor() {}

void send_request(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest) {}

void send_poll(ClientRequestInfo_ptr ri)
throw(CORBA::SystemException) {}

void receive_reply(ClientRequestInfo_ptr ri)
throw(CORBA::SystemException) {}

void receive_exception(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest)
{
cout << "Reply Status: " << ri->reply_status() << endl;
}

void receive_other(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest) {}

char* name()
throw(CORBA::SystemException)
{
return CORBA::string_dup("MyInterceptor");
}

void destroy() {}
};


class ORBInitializerImpl : public ORBInitializer {
IOP::Codec_var codec;
ClientInterceptor* clientInterceptor;
public:
ORBInitializerImpl() {}
~ORBInitializerImpl() {}

void pre_init(ORBInitInfo_ptr info) {
IOP::CodecFactory_var codec_factory = info->codec_factory();
IOP::Encoding cdr_encoding = {IOP::ENCODING_CDR_ENCAPS, 1, 2};
codec = codec_factory->create_codec(cdr_encoding);

clientInterceptor = new ClientInterceptor(codec);

info->add_client_request_interceptor(clientInterceptor);
}

void post_init(ORBInitInfo_ptr info) {}
};

int main(int argc, char** argv) {
ORBInitializerImpl* ini = new ORBInitializerImpl();
PortableInterceptor::register_orb_initializer(ini);

CORBA::ORB* orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();

CORBA::Object_var obj = orb->string_to_object("corbaloc::localhost:9999");
CORBA::Request_var req;
req = obj->_request("foo");
req->invoke();

return 0;
};

Thanks,
Ricardo Cosme
Karel Gardas
2010-06-22 10:13:35 UTC
Permalink
Hi Ricardo,

this is indeed an issue and your fix is right. It also needs to be done
in second method of the same name which is just below the code you've
fixed. Anyway, the fix is now pushed upstream.

Thanks,
Karel
Post by Ricardo Cosme
Hi,
When I invoke a method that gives me an IDL:omg.org/CORBA/COMM_FAILURE:1.0,
my receive_exception() implementation receives a ri->reply_status() with
an USER_EXCEPTION value, but COMM_FAILURE is a SYSTEM_EXCEPTION.
I noticed that receive_exception_ip(), in pi_impl.cc:2245, doesn't use
reply_status
//pi_impl.cc
2254: cri->reply_status(PortableInterceptor::USER_EXCEPTION);
cri->reply_status(reply_status);
I'm using Mico 2.3.13.
#include <CORBA.h>
using namespace std;
using namespace PortableInterceptor;
class ClientInterceptor : public ClientRequestInterceptor {
IOP::Codec_ptr cdr_codec;
ClientInterceptor(IOP::Codec_ptr pcdr_codec) {}
~ClientInterceptor() {}
void send_request(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest) {}
void send_poll(ClientRequestInfo_ptr ri)
throw(CORBA::SystemException) {}
void receive_reply(ClientRequestInfo_ptr ri)
throw(CORBA::SystemException) {}
void receive_exception(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest)
{
cout << "Reply Status: " << ri->reply_status() << endl;
}
void receive_other(ClientRequestInfo_ptr ri)
throw(
CORBA::SystemException,
PortableInterceptor::ForwardRequest) {}
char* name()
throw(CORBA::SystemException)
{
return CORBA::string_dup("MyInterceptor");
}
void destroy() {}
};
class ORBInitializerImpl : public ORBInitializer {
IOP::Codec_var codec;
ClientInterceptor* clientInterceptor;
ORBInitializerImpl() {}
~ORBInitializerImpl() {}
void pre_init(ORBInitInfo_ptr info) {
IOP::CodecFactory_var codec_factory = info->codec_factory();
IOP::Encoding cdr_encoding = {IOP::ENCODING_CDR_ENCAPS, 1, 2};
codec = codec_factory->create_codec(cdr_encoding);
clientInterceptor = new ClientInterceptor(codec);
info->add_client_request_interceptor(clientInterceptor);
}
void post_init(ORBInitInfo_ptr info) {}
};
int main(int argc, char** argv) {
ORBInitializerImpl* ini = new ORBInitializerImpl();
PortableInterceptor::register_orb_initializer(ini);
CORBA::ORB* orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
CORBA::Object_var obj = orb->string_to_object("corbaloc::localhost:9999");
CORBA::Request_var req;
req = obj->_request("foo");
req->invoke();
return 0;
};
Thanks,
Ricardo Cosme
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Mico-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mico-devel
--
Karel Gardas ***@objectsecurity.com
ObjectSecurity Ltd. http://www.objectsecurity.com
Loading...