harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r572649 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/InetAddress.java test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
Date Tue, 04 Sep 2007 12:33:15 GMT
Author: tellison
Date: Tue Sep  4 05:33:14 2007
New Revision: 572649

URL: http://svn.apache.org/viewvc?rev=572649&view=rev
Log:
Lookup of empty string InetAddress should return loopback adapter address.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=572649&r1=572648&r2=572649&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java Tue
Sep  4 05:33:14 2007
@@ -168,12 +168,9 @@
      */
     public static InetAddress[] getAllByName(String host)
             throws UnknownHostException {
-        if (host == null) {
+        if (host == null || 0 == host.length()) {
             return new InetAddress[] { preferIPv6Addresses() ? Inet6Address.LOOPBACK
                     : LOOPBACK };
-        }
-        if (0 == host.length()) {
-            throw new UnknownHostException(Msg.getString("K0038")); //$NON-NLS-1$
         }
 
         if (isHostName(host)) {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java?rev=572649&r1=572648&r2=572649&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java
Tue Sep  4 05:33:14 2007
@@ -203,6 +203,11 @@
         assertEquals("Assert 0: No loopback address", 1, ia.length);
         assertTrue("Assert 1: getAllByName(null) not loopback",
                 ia[0].isLoopbackAddress());
+        
+        ia = InetAddress.getAllByName("");
+        assertEquals("Assert 2: No loopback address", 1, ia.length);
+        assertTrue("Assert 3: getAllByName(\"\") not loopback",
+                ia[0].isLoopbackAddress());
     }
 
     /**



Mime
View raw message