river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r928951 - in /incubator/river/jtsk/trunk: src/org/apache/river/security/policy/util/PolicyEntry.java test/src/org/apache/river/security/policy/util/PolicyEntryTest.java
Date Tue, 30 Mar 2010 00:53:30 GMT
Author: peter_firmstone
Date: Tue Mar 30 00:53:29 2010
New Revision: 928951

URL: http://svn.apache.org/viewvc?rev=928951&view=rev
Log:
Slight PolicyEntry refactoring.

Modified:
    incubator/river/jtsk/trunk/src/org/apache/river/security/policy/util/PolicyEntry.java
    incubator/river/jtsk/trunk/test/src/org/apache/river/security/policy/util/PolicyEntryTest.java

Modified: incubator/river/jtsk/trunk/src/org/apache/river/security/policy/util/PolicyEntry.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/org/apache/river/security/policy/util/PolicyEntry.java?rev=928951&r1=928950&r2=928951&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/org/apache/river/security/policy/util/PolicyEntry.java
(original)
+++ incubator/river/jtsk/trunk/src/org/apache/river/security/policy/util/PolicyEntry.java
Tue Mar 30 00:53:29 2010
@@ -46,16 +46,20 @@ import java.util.Set;
  * 
  * 
  */
-public class PolicyEntry {
+public final class PolicyEntry {
 
     // Store CodeSource
     private final CodeSource cs;
 
     // Array of principals 
     private final List<Principal> principals;
+    private static final List<Principal> noPrincipals = 
+            Collections.unmodifiableList(new ArrayList<Principal>(0));
 
     // Permissions collection
     private final Collection<Permission> permissions;
+    private static final Collection<Permission> noPermissions = 
+            Collections.unmodifiableCollection(new HashSet<Permission>(0));
     
     private transient final int hashcode;
 
@@ -67,14 +71,13 @@ public class PolicyEntry {
             Collection<? extends Permission> permissions) {
         this.cs = (cs != null) ? normalizeCodeSource(cs) : null;
         if ( prs == null || prs.isEmpty()) {
-            this.principals = new ArrayList<Principal>(0);
+            this.principals = noPrincipals;
         }else{
             this.principals = new ArrayList<Principal>(prs.size());
             this.principals.addAll(prs);
         }
         if (permissions == null || permissions.isEmpty()) {
-            Set<Permission> perm = new HashSet<Permission>(0);
-            this.permissions = Collections.unmodifiableCollection(perm);
+            this.permissions = noPermissions;
         }else{
             Set<Permission> perm = new HashSet<Permission>(permissions.size());
             perm.addAll(permissions);
@@ -141,7 +144,7 @@ public class PolicyEntry {
      * PolicyEntry, may be <code>null</code>.
      */
     public Collection<Permission> getPermissions() {
-        if (permissions.isEmpty()) return null; // not sure if this is good needs further
investigation
+//        if (permissions.isEmpty()) return null; // not sure if this is good needs further
investigation
         return permissions;
     }
 

Modified: incubator/river/jtsk/trunk/test/src/org/apache/river/security/policy/util/PolicyEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/org/apache/river/security/policy/util/PolicyEntryTest.java?rev=928951&r1=928950&r2=928951&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/test/src/org/apache/river/security/policy/util/PolicyEntryTest.java
(original)
+++ incubator/river/jtsk/trunk/test/src/org/apache/river/security/policy/util/PolicyEntryTest.java
Tue Mar 30 00:53:29 2010
@@ -50,12 +50,12 @@ public class PolicyEntryTest extends Tes
     public void testCtor() {
         PolicyEntry pe = new PolicyEntry(null, null, null);
         assertTrue(pe.isVoid());
-        assertNull(pe.getPermissions());
+        assertTrue(pe.getPermissions().isEmpty());
 
         pe = new PolicyEntry(new CodeSource(null, (Certificate[])null),
             new ArrayList(), new ArrayList());
         assertTrue(pe.isVoid());
-        assertNull(pe.getPermissions());
+        assertTrue(pe.getPermissions().isEmpty());
 
         Collection perms = Arrays.asList(new Permission[] {
             new SecurityPermission("dsfg"), new AllPermission() });



Mime
View raw message