harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r375576 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/Inet6Address.java main/java/java/net/InetAddress.java test/java/org/apache/harmony/tests/java/net/InetAddressTest.java
Date Tue, 07 Feb 2006 11:10:49 GMT
Author: tellison
Date: Tue Feb  7 03:09:57 2006
New Revision: 375576

URL: http://svn.apache.org/viewcvs?rev=375576&view=rev
Log:
Fix for HARMONY-56 (java.net.InetAddress.getAllByName(null) throws UnknownHostException instead
of valid InetAddress)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java?rev=375576&r1=375575&r2=375576&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
Tue Feb  7 03:09:57 2006
@@ -27,10 +27,10 @@
 
 	private static final long serialVersionUID = 6880410070516793377L;
 
-	final static byte[] any_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-			0, 0 };
-
-	static InetAddress ANY = new Inet6Address(any_bytes);
+	static final byte[] any_bytes = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+	static final byte[] localhost_bytes = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
+	static final InetAddress ANY = new Inet6Address(any_bytes);
+	static final InetAddress LOOPBACK = new Inet6Address(localhost_bytes, "localhost"); 
 
 	int scope_id = 0;
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=375576&r1=375575&r2=375576&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
Tue Feb  7 03:09:57 2006
@@ -164,7 +164,10 @@
 	 */
 	public static InetAddress[] getAllByName(String host)
 			throws UnknownHostException {
-		if (host == null || 0 == host.length())
+		if (host == null) {
+			return new InetAddress[]{preferIPv6Addresses() ? Inet6Address.LOOPBACK : LOOPBACK};
+		}
+		if (0 == host.length())
 			throw new UnknownHostException(Msg.getString("K0038"));
 
 		if (isHostName(host)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/InetAddressTest.java?rev=375576&r1=375575&r2=375576&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/InetAddressTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/InetAddressTest.java
Tue Feb  7 03:09:57 2006
@@ -23,6 +23,18 @@
 public class InetAddressTest extends TestCase {
 
 	/**
+	 * @tests java.net.InetAddress#getAllByName(java.lang.String)
+	 */
+	public void test_getAllByNameLjava_lang_String()
+			throws UnknownHostException {
+		// Regression for HARMONY-56
+		InetAddress[] ia = InetAddress.getAllByName(null);
+		assertEquals("Assert 0: No loopback address", 1, ia.length);
+		assertTrue("Assert 1: getAllByName(null) not loopback",
+				ia[0].isLoopbackAddress());
+	}
+
+	/**
 	 * @tests java.net.InetAddress#getByAddress(byte[])
 	 */
 	public void test_getByAddress() {



Mime
View raw message