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

UnknownHostException contains wrong error message

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.2
    • core-libs
    • beta
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux jethro.dellroad.org 2.4.26 #2 Wed May 12 14:52:12 CDT 2004 i686 i686 i386
      GNU/Linux


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      RedHat Linux 9


      A DESCRIPTION OF THE PROBLEM :
      If you invoke InetAddress.getByName() with a bogus name, the error message
      in the UnknownHostException is repetitive. It contains the bogus name twice.
      Instead it should contain the error message, then the bogus name.

      E.g. InetAddress.getByName("foobar") gives this:

         java.net.UnknownHostException: foobar: foobar

      Instead it should give e.g. this:

          java.net.UnknownHostException: foobar: host not found

      or somesuch.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test program below.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Exception in thread "main" java.net.UnknownHostException: foobar: Host not found
              at java.net.InetAddress.getAllByName0(InetAddress.java:1011)
              at java.net.InetAddress.getAllByName0(InetAddress.java:981)
              at java.net.InetAddress.getAllByName(InetAddress.java:975)
              at java.net.InetAddress.getByName(InetAddress.java:889)
              at xx.main(xx.java:4)

      ACTUAL -
      Exception in thread "main" java.net.UnknownHostException: foobar: foobar
              at java.net.InetAddress.getAllByName0(InetAddress.java:1011)
              at java.net.InetAddress.getAllByName0(InetAddress.java:981)
              at java.net.InetAddress.getAllByName(InetAddress.java:975)
              at java.net.InetAddress.getByName(InetAddress.java:889)
              at xx.main(xx.java:4)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.InetAddress;

      public class Test {
          public static void main(String[] args) throws Exception {
              InetAddress.getByName("foobar");
          }
      }
      ---------- END SOURCE ----------
      ###@###.### 2005-03-25 20:32:40 GMT

            jccollet Jean-Christophe Collet (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: