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

InetAddress.getLocalHost() failed in returning chinese local host name

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b30
    • CPU:
      x86
    • OS:
      windows_2003
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        c:>java -version
        java version "1.6.0_03"
        Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
        Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        c:> ver
        Microsoft Windows [çæ¬ 5.2.3790]

        A DESCRIPTION OF THE PROBLEM :
        the InetAddress.getLocalHost() works fine in jre 1.5.0_03, but fails to fetch chinese local host name in jre 1.6.0_03.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        assume the host name is "中æ_æµè¯", which have to be a chinese presenting, and the running os is Windows 2003 Standard Edition with SP2


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        with jre 1.5.0_03, it print like:
        host : 中æ_æµè¯
        -42 -48 -50 -60 95 -78 -30 -54 -44
        it corretly presents my host name
        ACTUAL -
        with jre 1.6.0_03 , it prints like:
        host : ????_???
        63 63 63 63 95 63 63 63


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
             try {
                    InetAddress localHost = InetAddress.getLocalHost();
                    String hostName = localHost.getHostName();
                    
                    System.out.println("host\t: " + hostName);
                    byte[] bytes = hostName.getBytes();
                    for(byte b : bytes){
                        System.out.print(b + " ");
                    }
                    System.out.println();

                } catch (Exception ex) {
                    ex.printStackTrace(System.out);
                }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        I am going to use this localhost name to get all local IP addr later, but with "????", it is sure to throw java.net.UnknownHostException.

        downgrade jre environment to 1.5.

        Release Regression From : 5.0u3
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                chegar Chris Hegarty
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: