JDK-5082105 : InetAddress.isReachable() leaves open handles after execution
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-08-03
  • Updated: 2012-10-09
  • Resolved: 2004-09-10
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.
Other JDK 6
5.0u1 01Fixed 6Fixed
Description

Name: jl125535			Date: 08/03/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b59)
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b59, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Versione 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
Both builds "b58" and "b59" of j2sdk 1.5.0 are displaying behavior similar to that described by bug 5061568.

Snapshot version 1.5.0 b58 indicates that this bug has been fixed.

Here is the problem I found.

I executed isReachable on a list of different hosts and using taskmanager I found that there are handles never closed.
Using a better inspector instrumentation, like "process explorer" by sysinternals.com, I found that the opened handles are simply opened sockets.
So I think that the problem depicted by bug  5061568 has not been resolved

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
just write a simple program that check isReachable on a list of different hosts. If you see handle count of the process, it never decrease!

launch the given test case as 
> java Test host1 host2 host3 host4 host5 host6 host7

It pings regurarly these hosts then asks to press "enter". So I can check if handles have been closed with a monitoring program.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.net.*;

class Test{
  public static void main(String[] args){
    while(true)
    try{
      System.out.println("GO ON? press enter!");
      System.in.read();
      System.in.read();

      for(int i=0; i<args.length; i++){
        InetAddress inet = InetAddress.getByName(args[i]);
        System.out.print(args[i]+" is reachable? ");
        System.out.print(inet.isReachable(3000));
        inet = null;
        System.out.println();
      }
      System.gc();
    }catch(Exception e){
      e.printStackTrace();
    }
  }
} 

---------- END SOURCE ----------
(Incident Review ID: 289950) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01 mustang
15-09-2004

EVALUATION Before the fix for 5061568 the code would use up 3 handles, after only 1 handle per call is used. What happens is that an event is created with WSACreateEvent() but is not closed (WSACloseEvent() should be called). So the handle leaked is an Event handle, not as serious as a Socket, but still needs to be fixed as soon as possible. First update to Tiger would be the right target. ###@###.### 2004-08-12
12-08-2004