Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 69102 invoked from network); 10 Feb 2006 04:53:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Feb 2006 04:53:27 -0000 Received: (qmail 30341 invoked by uid 500); 10 Feb 2006 04:53:20 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 30262 invoked by uid 500); 10 Feb 2006 04:53:19 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 30237 invoked by uid 99); 10 Feb 2006 04:53:19 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Feb 2006 20:53:17 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 88765DE for ; Fri, 10 Feb 2006 05:52:56 +0100 (CET) Message-ID: <1383845874.1139547176557.JavaMail.jira@ajax.apache.org> Date: Fri, 10 Feb 2006 05:52:56 +0100 (CET) From: "Paulex Yang (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Commented: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup In-Reply-To: <1270834374.1139547175586.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-84?page=comments#action_12365837 ] Paulex Yang commented on HARMONY-84: ------------------------------------ A suggested simple fix is rewrite the toString() as below: public String toString() { return (hostName==null?"":hostName)+"/"+getHostAddress(); } > 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"); > System.out.println(addr); > InetAddress addr2 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); > System.out.println(addr2); > } > } > > 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