JDK-6210230 : REGRESSION: jdk 1.5.0 and Exception when calling orb.disconnect()
  • Type: Bug
  • Component: other-libs
  • Sub-Component: corba:orb
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2004-12-17
  • Updated: 2010-04-02
  • Resolved: 2005-03-24
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
SunOS oman 5.9 Generic_117171-12 sun4u sparc SUNW,Sun-Blade-1500

A DESCRIPTION OF THE PROBLEM :
With java 1.5.0 exceptions are thrown if "orb.disconnect(servant)" is called.
Furthermore the connection to the server application is not freed (checked it with lsof (list open files) 4.73) and the port remains occupied.

This becomes a problem if clients (through a webapp and tomcat) are opening connections to the orb and they aren't removed properly with disconnect(): this leads to the effect that all ports on the machine running the ORB (omniOrb 4.0.3) are blocked after a certain time and no further connections are possible (the only solution would be to stop/start tomcat which frees all ports).

Exception which is thrown under jdk1.5.0 (no problem with 1.4.2_x versions):
-----------------------------------------------------
Dec 15, 2004 10:31:43 AM com.sun.corba.se.impl.orb.ORBImpl disconnect
WARNING: "IOP02310202: (OBJ_ADAPTER) Error in connecting servant to ORB"
org.omg.CORBA.OBJ_ADAPTER:   vmcid: SUN  minor code: 202  completed: No
       at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8045)
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8063)
        at com.sun.corba.se.impl.orb.ORBImpl.disconnect(ORBImpl.java:1487)
        at Client.ORBClient.release(Unknown Source)
        at Client.samples.Stresser.main(Unknown Source)
Caused by: java.lang.RuntimeException: TOAImpl.disconnect can not be called on com.sun.corba.se.impl.protocol.NotLocalLocalCRDImpl@14e3f41
        at com.sun.corba.se.impl.oa.toa.TOAImpl.disconnect(TOAImpl.java:206)
        at com.sun.corba.se.impl.orb.ORBImpl.disconnect(ORBImpl.java:1485)
        ... 2 more

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create a connection to an orb/get a reference:
-----------------------------------
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.)

2. do whatever you want to do....

3. if all work is done and you are finished with, release and clean up:
-------------------------------------------------
  if(objRef!=null){
    if(orb!=null){
      orb.disconnect(objRef);  // causes exception in java 1.5.0
      orb.shutdown(false);
      orb.destroy();
    }
    objRef._release();
  }
  objRef=null;
  orb=null;


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- no exception thrown when calling orb.disconnect()
- that all connections are freed
result from lsof after orb.disconnect() ended in an exception:
# lsof -c java | grep oman.krinfo
java     1559 user400    8u  IPv4 0x3021db79548    0t32409        TCP guam:33649->oman.krinfo.ch:62522 (ESTABLISHED)
java     1564 user400   10u  IPv4 0x309b94176d8      0t313        TCP guam:33655->oman.krinfo.ch:40695 (ESTABLISHED)
java     1564 user400   11u  IPv4 0x3000528c658      0t558        TCP guam:33655->oman.krinfo.ch:40827 (ESTABLISHED)
java    10603 user400    8u  IPv4 0x309b9405b70      0t515        TCP guam:41524->oman.krinfo.ch:40697 (ESTABLISHED)
java    10603 user400    9u  IPv4 0x302f85b87a8      0t996        TCP guam:41524->oman.krinfo.ch:40828 (ESTABLISHED)
java    10603 user400   11u  IPv4 0x304302c5e60     0t7062        TCP guam:41524->oman.krinfo.ch:65495 (ESTABLISHED)
java    10603 user400   13u  IPv4 0x302f859c1c0      0t312        TCP guam:41524->oman.krinfo.ch:40809 (ESTABLISHED)

i.e. connections remain ESTABLISHED and ports are taken....
EXCPECTED RESULT SHOULD BE:
# lsof -c java | grep oman.krinfo

ACTUAL -
see above: connections remain ESTABLISHED, ports occupied

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Dec 15, 2004 10:31:43 AM com.sun.corba.se.impl.orb.ORBImpl disconnect
WARNING: "IOP02310202: (OBJ_ADAPTER) Error in connecting servant to ORB"
org.omg.CORBA.OBJ_ADAPTER:   vmcid: SUN  minor code: 202  completed: No
       at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8045)
        at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8063)
        at com.sun.corba.se.impl.orb.ORBImpl.disconnect(ORBImpl.java:1487)
        at Client.ORBClient.release(Unknown Source)
        at Client.samples.Stresser.main(Unknown Source)
Caused by: java.lang.RuntimeException: TOAImpl.disconnect can not be called on com.sun.corba.se.impl.protocol.NotLocalLocalCRDImpl@14e3f41
        at com.sun.corba.se.impl.oa.toa.TOAImpl.disconnect(TOAImpl.java:206)
        at com.sun.corba.se.impl.orb.ORBImpl.disconnect(ORBImpl.java:1485)
        ... 2 more

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
org.omg.CORBA.ORB orb = null;
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.)
}

private void release(){
  if(objRef!=null){
    if(orb!=null){
      orb.disconnect(objRef);  // causes exception in java 1.5.0
      orb.shutdown(false);
      orb.destroy();
    }
    objRef._release();
  }
  objRef=null;
  orb=null;
}
---------- END SOURCE ----------

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2004-12-17 21:56:03 GMT

Comments
EVALUATION This is an interesting case. What seems to be happening here is that there is an error in the test case, and the code in JDK 1.4.2 did not correctly check for the error. This part of the ORB in JDK 1.5 has been rewritten and does check for the error. ORB.disconnect() should only be called on objref that were connected to the same ORB using ORB.connect(). The test program here is clearly trying to clean up (generally a good thing) by calling disconnect on an objref that was obtained from a name service lookup. disconnect should never be called for such object references. Instead, simply allow the object reference to be garbage collected. In summary, this is not a bug. ###@###.### 2005-03-24 18:05:08 GMT
24-03-2005