harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r448765 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/SocketPermission.java test/java/tests/api/java/net/SocketPermissionTest.java
Date Fri, 22 Sep 2006 01:55:09 GMT
Author: pyang
Date: Thu Sep 21 18:55:09 2006
New Revision: 448765

URL: http://svn.apache.org/viewvc?view=rev&rev=448765
Log:
Apply patch for HARMONY-1462 ([classlib][luni] SocketPermission does not accept '*' as a port
number)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketPermission.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketPermission.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketPermission.java?view=diff&rev=448765&r1=448764&r2=448765
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketPermission.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/SocketPermission.java
Thu Sep 21 18:55:09 2006
@@ -303,6 +303,13 @@
 		if ((lastIdx > -1) && (lastIdx > endOfIPv6Addr)) {
 			try {
 				len = hostString.length();
+                // if hostString ends with ":*", such as "localhost:*"
+                // the port range should be 0-65535
+                if (hostString.endsWith(":*")) { //$NON-NLS-1$
+                    portMin = 0;
+                    portMax = 65535;
+                    return;
+                }
 				// look for a '-' after the colon
 				negidx = hostString.indexOf('-', lastIdx);
 				if (negidx == lastIdx + 1) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java?view=diff&rev=448765&r1=448764&r2=448765
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java
Thu Sep 21 18:55:09 2006
@@ -54,6 +54,15 @@
 		assertEquals("Wrong name1", "localhost", sp1.getName());
 		SocketPermission sp2 = new SocketPermission(":80", "connect");
 		assertEquals("Wrong name2", ":80", sp2.getName());
+        
+		// regression for HARMONY-1462
+        SocketPermission sp3 = new SocketPermission("localhost:*", "listen");
+        assertEquals("Wrong name3", "localhost:*", sp3.getName());
+        // for all ports
+        SocketPermission spAllPorts = new SocketPermission("localhost:0-65535",
+                "listen");
+        assertTrue("Port range error", sp3.implies(spAllPorts));
+        assertTrue("Port range error", spAllPorts.implies(sp3));
 	}
 
 	/**



Mime
View raw message