JDK-6596792 : InetAddress.isReachable returns true when pointing an unreachable IP
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_redhat_9.0
  • CPU: x86
  • Submitted: 2007-08-24
  • Updated: 2010-08-05
  • Resolved: 2007-08-24
Related Reports
Duplicate :  
Description
InetAddress.isReachable returns true when pointing a host ip that actually does not exist.

OS: RHEL4 or RHEL AS 3.
JDK: jdk 6u2, jdk 5u2

Below is the test program. To reproduce you must run the TP with root authority.

---->
import java.net.*;

class Multiping extends Thread {
    private InetAddress addr;
    private boolean reachable;
    static volatile boolean finish;

    public static void main( String arg[] ) throws Exception{
        new Multiping("192.168.3.2", true).start(); // put reachable host ip here
        new Multiping("10.210.45.39", false).start(); // put unreachable host ip
        finish = false;

        Thread.sleep(20000);
        finish = true;
    }

    Multiping( String str, boolean f ) {
        reachable = f;
        try {
            addr = InetAddress.getByName( str );
        }
        catch ( UnknownHostException e ) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public void run() {
        try {
            while( finish == false ) {
                boolean result = addr.isReachable(3000);
                if ( result != reachable ) {
                    if ( result ) {
                        System.out.println(addr+":reachable ... unexpected result");
                        System.exit(1);
                    }
                    else {
                        System.out.println(addr+":unreachable ... unexpected result");
                        System.exit(1);
                    }
                }
            }
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
}
<---- 

The following is the TP's result I ran.

[root@kronos isReachable]# /home/xz137640/jdk/6u2/bin/java Multiping
/10.210.45.39:reachable ... unexpected result

It seems that the implementation can not determine the response is from which host because of raw packet using.

Comments
EVALUATION This is a duplicate of 6595834.
24-08-2007