harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r728589 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/UnresolvedPermission.java test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
Date Mon, 22 Dec 2008 03:23:18 GMT
Author: tonywu
Date: Sun Dec 21 19:23:17 2008
New Revision: 728589

URL: http://svn.apache.org/viewvc?rev=728589&view=rev
Log:
Apply patch for HARMONY-6043 [classlib] [security] UnresolvedPermission.equals(Object) doesn't
works well, with following changes:
1. avoid NullPointerException
2. add another scenario test

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java?rev=728589&r1=728588&r2=728589&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
Sun Dec 21 19:23:17 2008
@@ -83,7 +83,10 @@
         this.type = type;
         this.name = name;
         this.actions = actions;
-        this.targetCerts = certs;
+        if (certs != null) {
+            this.targetCerts = new Certificate[certs.length];
+            System.arraycopy(certs, 0, targetCerts, 0, certs.length);
+        }
         hash = 0;
     }
 
@@ -150,6 +153,10 @@
         if (length > 0) {
             boolean found;
             for (int i = 0; i < length; i++) {
+            	// Skip the checking for null
+            	if(certs1[i] == null){
+            		continue;
+            	}
                 found = false;
                 for (int j = 0; j < length; j++) {
                     if (certs1[i].equals(certs2[j])) {
@@ -164,6 +171,9 @@
             }
 
             for (int i = 0; i < length; i++) {
+            	if(certs2[i] == null){
+            		continue;
+            	}
                 found = false;
                 for (int j = 0; j < length; j++) {
                     if (certs2[i].equals(certs1[j])) {

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java?rev=728589&r1=728588&r2=728589&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
Sun Dec 21 19:23:17 2008
@@ -217,11 +217,23 @@
                 new java.security.cert.Certificate[2]);
         UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                 new java.security.cert.Certificate[2]);
-        try {
-            up1.equals(up2);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // Expected
-        }
+        // Non-bug difference, RI throw NPE here.
+        assertEquals(up1, up2);
+    }
+
+    public void test_Equals_Scenario11() {
+        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
+                new java.security.cert.Certificate[] { cert1, cert2 });
+        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
+                new java.security.cert.Certificate[] { cert1, null, cert2 });
+        assertFalse(up1.equals(up2));
+    }
+    
+    public void test_Equals_Scenario12() {
+        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
+                new java.security.cert.Certificate[] { cert1, null, null });
+        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
+                new java.security.cert.Certificate[] { cert1, null, cert1 });
+        assertEquals(up1, up2);
     }
 }



Mime
View raw message