This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH for InetAddress.getByName: empty String -> localhost

* gcc/libjava/java/net/ With this patch getByName (String hostname) returns 
the hostname of the local machine for "" (empty String) - as it already does for passing 'null'
to the method.
This is necessary for parsing URLs like //:8888/xxxxx, which is desirable for compatibility 
with other javas.

Index: gcc/libjava/java/net/
RCS file: /cvs/gcc/gcc/libjava/java/net/,v
retrieving revision 1.26
diff -u -r1.26
--- gcc/libjava/java/net/	30 Nov 2003 21:02:56 -0000	1.26
+++ gcc/libjava/java/net/	8 Jan 2004 23:46:31 -0000
@@ -573,7 +573,7 @@
    * Returns an InetAddress object representing the IP address of the given
    * hostname.  This name can be either a hostname such as ""
    * or an IP address in dotted decimal format such as "".  If the
-   * hostname is null, the hostname of the local machine is supplied by
+   * hostname is null or "", the hostname of the local machine is supplied by
    * default.  This method is equivalent to returning the first element in
    * the InetAddress array returned from GetAllByName.
@@ -594,7 +594,7 @@
       s.checkConnect (hostname, -1);
     // Default to current host if necessary
-    if (hostname == null)
+    if (hostname == null || hostname.length() == 0)
       return getLocalHost();
     // Assume that the host string is an IP address

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]