harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r651488 - 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 Fri, 25 Apr 2008 05:27:53 GMT
Author: ndbeyer
Date: Thu Apr 24 22:27:42 2008
New Revision: 651488

URL: http://svn.apache.org/viewvc?rev=651488&view=rev
Log:
HARMONY-5784 - just put the host name in the UnknownHostException

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=651488&r1=651487&r2=651488&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 Thu
Apr 24 22:27:42 2008
@@ -406,7 +406,7 @@
         // now try the negative cache
         String failedMessage = NegativeCache.getFailedMessage(host);
         if (failedMessage != null) {
-            throw new UnknownHostException(host + " - " + failedMessage); //$NON-NLS-1$
+            throw new UnknownHostException(host);
         }
 
         InetAddress anInetAddress;
@@ -415,7 +415,8 @@
         } catch (UnknownHostException e) {
             // put the entry in the negative cache
             NegativeCache.put(host, e.getMessage());
-            throw new UnknownHostException(host + " - " + e.getMessage()); //$NON-NLS-1$
+            // use host for message to match RI, save the cause for giggles
+            throw (UnknownHostException)new UnknownHostException(host).initCause(e);
         }
 
         Cache.add(anInetAddress);

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=651488&r1=651487&r2=651488&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
Thu Apr 24 22:27:42 2008
@@ -129,6 +129,23 @@
             }
         }
     }
+    
+    /**
+     * @tests java.net.InetAddress#getByName(String)
+     */
+    public void test_getByNameUnknownHostException() {
+        // Related to HARMONY-5784
+
+        // loop a few times to flex the negative cache paths
+        for (int i = 0; i < 5; i++) {
+            try {
+                InetAddress.getByName("unknown.unknown.bad");
+                fail("An UnknownHostException should have been thrown");
+            } catch (UnknownHostException e) {
+                assertEquals("unknown.unknown.bad", e.getMessage());
+            }
+        }
+    }
 
     /**
      * @tests java.net.InetAddress#equals(java.lang.Object)



Mime
View raw message