A DESCRIPTION OF THE REQUEST :
If a client connection to an ORB (omniORB in this case) is established from an application (i.e. a servlet) running under Tomcat (i.e. this app is running for weeks w/o being restarted) and all work with the orb is done, the connection to the orb should be released and all resources should be freed (especially the occupied port of course).
Though the recommendation in bug # 6210230 says to let the garbage collector clean up everything, this does not work:
- I ensured that no more refs to objRef are available (refs are explicitly set to null)
- the respective finalize() methods are called - but the connection remains established until either Tomcat is stopped/started or the server part of the application (bound to the orb) is restarted.
Though "objRef._release()", "orb.shutdown(false)" and "orb.destroy()" are called the ports to the orb remain occupied: objRef is the client stub created from the idlj compiler - and objRef extends ObjectImpl where "ObjectImpl._release()" calls "_get_delegate().release(this)". The Delegate is in my case a com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl object whose "release()" method is EMPTY.
There is no method available which can be called to release the resources in use.
Main problem: after a certain ammount of time, all ports are taken and it is not possible anymore to connect to the orb until - as described - either the server part or tomcat is restarted. (verified that the ports are taken with lsof (list open files) 4.73)
JUSTIFICATION :
To free up connections (i.e. close sockets) between orb client and server application and to avoid that all available system resources remain allocated.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
have a "disconnect()" or "release()" or "close()" method for client stubs as well - and not only the "orb.disconnect(servant)" method which can't be used for _is_local() == false objects as well.
ACTUAL -
client connections to orb remain open and aren't garbage collected
---------- BEGIN SOURCE ----------
my.package objRef = null;
private void init(){
org.omg.CORBA.ORB orb = ORB.init(args, props);
// get the root naming context
org.omg.CORBA.Object obj = orb.resolve_initial_references("name");
NamingContextExt nce=NamingContextExtHelper.narrow(obj);
objRef = "whatever"Helper.narrow(nce.resolve_str("service-name"));
// where "whatever" is the Helper class created from the idlj compiler.
}
// do some work with the client application....
private void release(){
if(objRef!=null){
ORB orb = (ObjectImpl)objRef)._orb();
if(orb!=null){
// causes exception in java 1.5.0,
// but used to work and cleaned up connections in java < 1.5
// orb.disconnect(objRef);
orb.shutdown(false);
orb.destroy();
}
objRef._release();
}
objRef=null;
orb=null;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
unfortunately there is no workaround except not upgrading to java 1.5 :-(