Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4938744

InetAddress.isReachable(nif,ttl,timeout) throws ConnectException on redhat AS2.1

XMLWordPrintable

    • b28
    • x86
    • linux_redhat_2.1
    • Verified

      InetAddress.isReachable(nif, ttl, timeout) throws a ConnectException on redhat advanced server 2.1 with an "Invalid argument" message. The same test passes on redhat 8.0 . The problem seems to be in the loopback interface of RH AS 2.1 .

      Steps to reproduce the problem:

      1. Compile and run the code given below on a Redhat Advanced Server 2.1 machine.
      2. The error is thrown.

      -----------------------BEGIN CODE------------------------
      import java.util.*;
      import java.net.*;
      import java.io.*;

      public class NIFBug{
              public static void main(String args[]){
                      NetworkInterface nif = null;
                      InetAddress sqeweb = null;
                      Enumeration <NetworkInterface> nifEnum = null;

                      try{
                              sqeweb = InetAddress.getByName("sqeweb.sfbay.sun.com");
                      }catch (UnknownHostException uhe){
                              uhe.printStackTrace();
                              System.exit(1);
                      }

                      try{
                              nifEnum = NetworkInterface.getNetworkInterfaces();
                              while (nifEnum.hasMoreElements()){
                                      nif = nifEnum.nextElement();
                                      try{
                                              System.out.println("nif is: " + nif);
                                              System.out.println("is sqeweb reachable? " +
                                                              sqeweb.isReachable(nif, 20, 10000));
                                      }catch (IOException ioe){
                                              System.err.println("IOException caught !!");
                                              ioe.printStackTrace();
                                      }
                              }
                      }catch (SocketException se){
                              System.err.println("SocketException caught !!");
                              se.printStackTrace();
                      }
              }
      }

      -----------------------END CODE--------------------------

      -----------------------BEGIN OUTPUT----------------------
      $ $JAVA_HOME/bin/java -showversion NIFBug
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b23)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b23, mixed mode)

      nif is: name:eth0 (eth0) index: 2 addresses:
      /10.12.151.152;

      is sqeweb reachable? true
      nif is: name:lo (lo) index: 1 addresses:
      /127.0.0.1;

      IOException caught !!
      java.net.ConnectException: Invalid argument
              at java.net.Inet4AddressImpl.isReachable0(Native Method)
              at java.net.Inet4AddressImpl.isReachable(Inet4AddressImpl.java:52)
              at java.net.InetAddress.isReachable(InetAddress.java:417)
              at NIFBug.main(NIFBug.java:24)
      $

      ------------------------END OUTPUT-----------------------

      -------------------BEGIN REDHAT 8.0 OUTPUT---------------
      $ $JAVA_HOME/bin/java -showversion NIFBug
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b23)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b23, mixed mode)

      nif is: name:eth0 (eth0) index: 3 addresses:
      /fe80:0:0:0:2d0:b7ff:fe4c:81e%3;
      /10.12.151.153;

      is sqeweb reachable? true
      nif is: name:lo (lo) index: 1 addresses:
      /0:0:0:0:0:0:0:1%1;
      /127.0.0.1;

      is sqeweb reachable? true
      $
      --------------------END REDHAT 8.0 OUTPUT----------------

            jccollet Jean-Christophe Collet (Inactive)
            kjethisunw Kanishk Jethi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: