JDK-6714797 : InitialContext.close does not close NIO socket connections
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.naming
  • Affected Version: 6u6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris
  • CPU: sparc
  • Submitted: 2008-06-16
  • Updated: 2011-02-21
  • Resolved: 2009-04-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u13-rev b06Fixed 7Fixed
Related Reports
Relates :  
Relates :  
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 http://hg.openjdk.java.net/jdk7/build/corba/rev/e0f7ed041196
25-12-2010

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

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
01-10-2008