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

InetAddress.getAllByName() doesn't return all IPs if target is an IP

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.1.7
    • core-libs
    • generic
    • generic

      The API documentation for this method states that it

      Determines all the IP addresses of a host, given the host's name. The host name can either be a machine name, such as "java.sun.com", or a
      string representing its IP address, such as "206.26.48.100".

      However, if an IP address is passed as a parameter, the only IP address that is
      returned is the address itself. This can be seen from the source in InetAddress.java:

      --------------------------------------------------------------------------------
          public static InetAddress getAllByName(String host)[]
          throws UnknownHostException {

          if (host == null || host.length() == 0) {
              throw new UnknownHostException("empty string");
          }

          if(Character.isDigit(host.charAt(0))) {
              InetAddress[] ret = new InetAddress[1];
              ret[0] = getByName(host);
              return ret;
          } else {
              return getAllByName0(host);
          }
          }

      --------------------------------------------------------------------------------

      This bug should not be confused with 4026796, which reported a separate problem.

            Unassigned Unassigned
            nrodinsunw Nick Rodin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: