classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] ensure LOCALHOST is used when localhost name is unsuabl


From: Mark Wielaard
Subject: Re: [cp-patches] ensure LOCALHOST is used when localhost name is unsuable
Date: Sun, 01 Jan 2006 14:50:47 +0100

Hi Raif,

On Tue, 2005-12-27 at 10:19 +1100, Raif S. Naffah wrote:
> pls. find attached a patch to do the above.  sometimes, the parameter 
> localhost (to the InetAddress.getAllByName(String) method) is an empty 
> string which causes an UnknownHostException to be thrown.  the patch 
> ensures that if this is the case LOCALHOST is used instead.

This looks sane. I committed it as follows (removed the commented out
code, moved the trim() up so we don't do it twice and added a comment
about trim in the ChangeLog entry).

2006-01-01  Raif S. Naffah  <address@hidden>

       * java/net/InetAddress.java (getAllByName): use LOCALHOST if
       localhost is null or is an empty string. Trim hostname before
       lookup.

Could you add a Mauve test for this?

Cheers,

Mark
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/InetAddress.java,v
retrieving revision 1.42
diff -u -r1.42 InetAddress.java
--- java/net/InetAddress.java   2 Jul 2005 20:32:39 -0000       1.42
+++ java/net/InetAddress.java   1 Jan 2006 13:50:15 -0000
@@ -649,8 +649,11 @@
 
     InetAddress[] addresses;
 
+    if (hostname != null)
+      hostname = hostname.trim();
+
     // Default to current host if necessary
-    if (hostname == null)
+    if (hostname == null || hostname.equals(""))
       {
        addresses = new InetAddress[1];
        addresses[0] = LOCALHOST;

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]