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

InetAddress.toString() causes DNS lookup -- can result in delay

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • generic
    • generic



      Name: skT45625 Date: 10/13/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      Calling the java.net.InetAddress.toString() method returns both the hostname
      and the host address, separated by a slash. To obtain the hostname, a DNS
      lookup may be performed.

      The documentation for toString() only says, "Converts this IP address to a
      String." It doesn't indicate that a DNS lookup for the hostname could happen.

      The toString() method should be changed to return only the result of
      getHostAddress(). A DNS lookup can fail, and can take several seconds to
      evaluate. In our case, several hundred machines are connecting within the
      space of a few seconds, and for each we log a message including the result of
      the InetAddress.toString(). The DNS lookup fails for many of these machines,
      and it takes over 8 minutes to handle the connections.

      Please either: 1) remove the getHostName() call from within toString(); or 2)
      modify the documentation so it is clear that both getHostAddress() and
      getHostName() are being called from within toString(), and that getHostName()
      can result in a DNS lookup if the name is not already cached.
      (Review ID: 110847)
      ======================================================================

            ywangsunw Yingxian Wang (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: