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

InetAddress.getAllByName fails to get all addresses for a computer.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1 P1
    • None
    • 1.1
    • core-libs
    • generic
    • generic

      InetAddress.getAllByName fails to get all addresses for a computer with multiple DNS entries. It also fails to get all addresses for a multi-homed computer.

      Steps to reproduce
      Compile and run the attached code. All host names should return multiple addresses.

      import java.io.PrintStream;
      import javasoft.sqe.harness.Status;

      import java.net.InetAddress;

      public class GetAllTest {

          public static void main( String argv[] ) {
              GetAllTest test = new GetAllTest( );
              Status s = test.run( argv, System.err, System.out );
              s.exit();
          }

          public Status run( String argv[], PrintStream log, PrintStream out ) {
              int iFailed = 0;
              /* Try to create multiple InetAddresses for the following
               * host names or addresses
               * 1) tachyon - has at least two DNS entries
               * 2) 129.144.86.151 - IP address for tachyon/interactive
               * 3) cafedead - a multi-homed host
               */
              try {
                  InetAddress addrs[] = InetAddress.getAllByName( "tachyon" );
                  if( addrs.length < 2 ) {
                      out.println( "tachyon failed: " + addrs.length );
                      ++iFailed;
                  }

                  addrs = InetAddress.getAllByName( "129.144.86.151" );
                  if( addrs.length < 2 ) {
                      out.println( "tachyon/interactive failed: " + addrs.length );
                      ++iFailed;
                  }

                  addrs = InetAddress.getAllByName( "cafedead" );
                  if( addrs.length < 2 ) {
                      out.println( "cafedead failed: " + addrs.length );
                      ++iFailed;
                  }

              }
              catch( Throwable t ) {
                  return Status.failed( t.toString() );
              }

              if( iFailed == 0 ) {
                  return Status.passed( "OKAY" );
              }
              else {
                  return Status.failed( iFailed + " tests failed" );
              }
              
          }
      }

            djbrown David Brown (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: