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

getHostName returns ip address

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6u7
    • core-libs
    • x86
    • linux

      FULL PRODUCT VERSION :
      # ./java -version
      java version "1.6.0_07"

      ADDITIONAL OS VERSION INFORMATION :
      All OS

      A DESCRIPTION OF THE PROBLEM :
      For some ip addresses getHostName returns ip address instead of resolving into domain name

      eg:
      # ./java ipres 137.227.5.37
      137.227.5.37

      Only on Redhat gcj version of java, getHostName() returns hostname for that ip

      # java -version java version "1.4.2"
      gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8) Copyright (C) 2006 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

      # java ipres 137.229.5.37
      rakof-ilo.alaska.edu

      I've default java security manager settings.


      nslookup is working fine for all ip.

      # nslookup 137.229.5.37
      Server: 10.206.194.12
      Address: 10.206.194.12#53

      Non-authoritative answer:
      37.5.229.137.in-addr.arpa name = rakof-ilo.alaska.edu.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run my ipres class

      # ./java ipres 137.227.5.37
      137.227.5.37


      ============code==================
      import java.net.*;
      class ipres
      {
      public static void main(String[] args)
      {
      String hostName;
      try {
      InetAddress address;
      address = InetAddress.getByName(args[0]);
      hostName = address.getHostName();
      System.out.println(hostName);
      }
      catch (Exception e)

      {
      System.out.println("Exception");
      }

      }
      }
      ===========================================


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      should return hostname (rakof-ilo.alaska.edu)
      ACTUAL -
      -# ./java ipres 137.227.5.37
      137.227.5.37



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      ============code==================
      import java.net.*;
      class ipres
      {
      public static void main(String[] args)
      {
      String hostName;
      try {
      InetAddress address;
      address = InetAddress.getByName(args[0]);
      hostName = address.getHostName();
      System.out.println(hostName);
      }
      catch (Exception e)

      {
      System.out.println("Exception");
      }

      }
      }
      ===========================================
      ---------- END SOURCE ----------

            Unassigned Unassigned
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: