You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Paulex Yang (JIRA)" <ji...@apache.org> on 2006/02/10 05:52:55 UTC

[jira] Created: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

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


[jira] Commented: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ 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:
<code>
	public String toString() {
		return (hostName==null?"":hostName)+"/"+getHostAddress();
	}
</code>

> 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


[jira] Resolved: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-84?page=all ]
     
Tim Ellison resolved HARMONY-84:
--------------------------------

    Resolution: Fixed

Paulex,

Fixed in LUNI module at repo revision 380663.

Please check that this fully resolves your problem.


> 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
>     Assignee: Tim Ellison
>     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


[jira] Commented: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-84?page=comments#action_12367918 ] 

Paulex Yang commented on HARMONY-84:
------------------------------------

The fix is fine, pls. close this issue, thank you, Tim.

> 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
>     Assignee: Tim Ellison
>     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


[jira] Closed: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-84?page=all ]
     
Tim Ellison closed HARMONY-84:
------------------------------


Verified by Paulex

> 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
>     Assignee: Tim Ellison
>     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


[jira] Assigned: (HARMONY-84) java.net.InetAddress() shouldn't perform reverse name lookup

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-84?page=all ]

Tim Ellison reassigned HARMONY-84:
----------------------------------

    Assign To: Tim Ellison

> 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
>     Assignee: Tim Ellison
>     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