Re: OB 4.20 sp2 -> Java 5.0: pb with callbacks

Dion Picco <[email protected]> Mon, 20 Jun 2005 10:29:14 -0230
Newsgroups gmane.comp.corba.orbacus
Organization IONA | Making Software Work Together TM
Message-ID <[email protected]>
Hi Fabrice,

On Mon, Jun 20, 2005 at 08:01:07AM +1100, Fabrice Bouye wrote:
> Thanks for the tip about catching the JTCException. But aren't both class 
> descending from std:exception ? I haven't looked at the sources yet.
> 
> After Google-ing for some time I finally found a way to fix the issue... 
> It seems someone poste almost the exact same question in the ORBacus mailing 
> list in 2001.
> 
> The answer is to use the _duplicate() method to avoid the reference from 
> beeing released when the addSeapodymRCListener() method exits.
> 
> m_listenerMap.insert(ListenerPair(clientAddr, 
> DSeapodymRCListener::_duplicate(listener)));
> 
> Everything works fine now when the fire method is executed and the clients 
> receive the event update correctly.
> 
> In the original post the guy used a map of _ptr objects to store the 
> references and some people warned him of possible memory leaks when 
> releasing the references. I guess I'm Ok if I use _var objects instead, 
> am I ?
> 
> ---- 
> Fabrice Bouyé (http://fabricebouye.cv.fm/) 
> Research Officer (Data) 
> Tel: +687 26 20 00 (Ext 411) 
> Oceanic Fisheries, Pacific Community 
> http://www.spc.int/ 

That's great that you have it fixed.  I didn't realize from your
previous emails that it was a reference-counting problem so I'm glad
that you managed to find the solution.

Regarding the exceptions: no, they are not both derived from
std::exception.  In fact, a few of the platforms that Orbacus supports
doesn't even have the std namespace itself.  And since the JTC isn't a
CORBA-specific library, it is not derived from CORBA::Exception.

And yes, the _var types decrement a reference count when they go out of
scope whereas _ptr types do not.  So if you duplicate a reference (you
are in fact increasing its reference count by 1 then) and do NOT store
it in a _var type, you would have to manually decrement the reference
count when it went out of scope.  By using _var types, it will decrement
automatically.

Hope that clears it up.

-- 
Dion Picco, Software Engineer
IONA Technologies Inc.
Team Orbacus - Your CORBA Source
mailto:[email protected]
http://www.orbacus.com
_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html