United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6714797 InitialContext.close does not close NIO socket connections
JDK-6714797 : InitialContext.close does not close NIO socket connections

Details
Type:
Bug
Submit Date:
2008-06-16
Status:
Resolved
Updated Date:
2011-02-21
Project Name:
JDK
Resolved Date:
2009-04-06
Component:
core-libs
OS:
solaris
Sub-Component:
javax.naming
CPU:
sparc
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u6
Fixed Versions:
6u13-rev (b06)

Related Reports
Backport:
Backport:
Backport:
Relates:
Relates:
Relates:

Sub Tasks

Description
This came as a customer concern on bug 4925258.

The test case did a loop on a creation on InitialContext and closing it immediately after connecting to appserver 8.2 EE.  After 2 mins timeout, the reader thread is stopped, so the fix for 4925258 is good.

However netstat reveals that the physical connection is not closed.

I am attaching the test case.

                                    

Comments
EVALUATION

Hi Sunita,

I have use below test applicatioin to verify the fix result.
I think fix result is ok.

cat HelloClient.java
--------------------------------------------------------
package hello;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;

public class HelloClient {

       public static void main(String[] args) {
               try {
                       Properties env = new Properties();
                       env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
                       env.put(Context.PROVIDER_URL, "iiop://129.158.147.250:38056");

                       Context initial = new InitialContext(env);
                       System.out.println("debug-1");

                       /* create context */
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();
                       initial = new InitialContext(env);
                       initial.close();

                       /* 10 seconds loop and run netstat -a to confirm connection status */
                       Thread.sleep(10000);
                       System.exit(1);

                       HelloHome home = (HelloHome) PortableRemoteObject.narrow(
                                       initial.lookup("Hello"), HelloHome.class);
                       System.out.println("debug-2");
                       Hello hello = home.create();
                       System.out.println("Message: " + hello.hello() );
               } catch (Exception ex) {
                       System.err.println("Caught an unexpected exception!");
                       ex.printStackTrace();
               }
       }
}
--------------------------------------------------------


[reproducte same issue with jdk1.6.0_04 as below]

bash-2.05# /masa/jdk/eric/jdk1.6.0_04/bin/java hello.HelloClient
debug-1
bash-2.05#
bash-2.05# netstat -a | grep 38056
sslab152.35084       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35088       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35089       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35090       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35091       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35092       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
sslab152.35093       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
bash-2.05# netstat -a | grep 38056
sslab152.35084       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35088       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35089       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35090       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35091       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35092       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35093       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT


[Can not reprocude same issue with fixed java which in j2sdk-image]

bash-2.05# /masa/jdk/eric/j2sdk-image/bin/java hello.HelloClient
debug-1
bash-2.05#

bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 ESTABLISHED***
bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35111       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35112       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35113       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35114       b2500.PRC.Sun.COM.38056 49640    263 49640      0 ESTABLISHED***
bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35111       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35112       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35113       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35114       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35115       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35116       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35111       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35112       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35113       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35114       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35115       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35116       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35111       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35112       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35113       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35114       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35115       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35116       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
bash-2.05# netstat -a | grep 38056
sslab152.35107       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35111       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35112       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35113       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35114       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35115       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT
sslab152.35116       b2500.PRC.Sun.COM.38056 49376      0 48776      0 TIME_WAIT


Could you please build a test binary for end-user , so that we can request end-user to verify it too?

Thanks & regards,
Eric
                                     
2008-10-01
EVALUATION

http://hg.openjdk.java.net/jdk7/tl/corba/rev/b2bd68ca8ff4
                                     
2010-11-08
EVALUATION

http://hg.openjdk.java.net/jdk7/build/corba/rev/e0f7ed041196
                                     
2010-12-25



Hardware and Software, Engineered to Work Together