harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulex Yang (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup
Date Fri, 10 Feb 2006 04:52:55 GMT
java.net.InetAddress() shouldn't perform reverse name lookup

         Key: HARMONY-84
         URL: http://issues.apache.org/jira/browse/HARMONY-84
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Paulex Yang
    Priority: Minor

Currently,  the java.net.InetAddress.toString() is as below:
    public String toString() {
        return getHostName() + "/" + getHostAddress();

    But actually the toString() should behave differently with getHostName()!
    the Java spec for toString():
        Converts this IP address to a String. The string returned is of the form: hostname
/ literal IP address. If the host name is unresolved, no reverse name service loopup is performed.
The hostname part will be represented by an empty string.
    and the spec for getHostName() says:
    If this InetAddress was created with a host name, this host name will be remembered and
returned; otherwise, a reverse name lookup will be performed and the result will be returned
based on the system configured name lookup service.

    Spec shows that toString() shouldn't perform reverse name lookup while getHostName() should!

    A simple test show this bug:
    public class ToStringTest{
    public static void main(String[] args) throws Exception{
        InetAddress addr = InetAddress.getByName("localhost");
        InetAddress addr2 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
    on RI, it outputs:

    and on Harmony, it outputs:

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message