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: <code> public String toString() { return getHostName() + "/" + getHostAddress(); } </code> But actually the toString() should behave differently with getHostName()! the Java spec for toString(): <spec> 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. </spec> and the spec for getHostName() says: <spec> 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> Spec shows that toString() shouldn't perform reverse name lookup while getHostName() should! A simple test show this bug: <code> public class ToStringTest{ public static void main(String[] args) throws Exception{ InetAddress addr = InetAddress.getByName("localhost"); System.out.println(addr); InetAddress addr2 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); System.out.println(addr2); } } </code> on RI, it outputs: localhost/127.0.0.1 /127.0.0.1 and on Harmony, it outputs: localhost/127.0.0.1 localhost/127.0.0.1 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira