harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r380663 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/InetAddress.java test/java/org/apache/harmony/tests/java/net/InetAddressTest.java
Date Fri, 24 Feb 2006 13:00:50 GMT
Author: tellison
Date: Fri Feb 24 05:00:45 2006
New Revision: 380663

URL: http://svn.apache.org/viewcvs?rev=380663&view=rev
Log:
Fix for HARMONY-84 (java.net.InetAddress() shouldn't perform reverse name lookup)

Modified:
    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/InetAddress.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=380663&r1=380662&r2=380663&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
Fri Feb 24 05:00:45 2006
@@ -487,7 +487,7 @@
 	 * @return String the description, as host/address
 	 */
 	public String toString() {
-		return getHostName() + "/" + getHostAddress();
+		return (hostName == null ? "" : hostName) + "/" + getHostAddress();
 	}
 
 	class CacheElement {

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=380663&r1=380662&r2=380663&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
Fri Feb 24 05:00:45 2006
@@ -46,4 +46,15 @@
 			// Expected
 		}
 	}
+	
+	/**
+	 * @tests java.net.InetAddress#toString()
+	 */
+	public void test_toString() throws UnknownHostException {
+		// Regression for HARMONY-84
+        InetAddress addr = InetAddress.getByName("localhost");
+        assertEquals("Assert 0: wrong string from name", "localhost/127.0.0.1", addr.toString());
+        InetAddress addr2 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
+        assertEquals("Assert 1: wrong string from address", "/127.0.0.1", addr2.toString());
+	}
 }



Mime
View raw message