7189490: More improvements to DomainCombiner checking
authormullan
Wed, 15 Aug 2012 15:31:30 -0400
changeset 14213 91ba926457c6
parent 14212 faa4afc89a09
child 14214 aa16457b32df
7189490: More improvements to DomainCombiner checking Reviewed-by: ahgross, jdn, vinnie
jdk/src/share/classes/java/security/AccessController.java
--- a/jdk/src/share/classes/java/security/AccessController.java	Sat Jul 28 19:42:50 2012 -0700
+++ b/jdk/src/share/classes/java/security/AccessController.java	Wed Aug 15 15:31:30 2012 -0400
@@ -290,11 +290,11 @@
      */
     public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
 
-        DomainCombiner dc = null;
         AccessControlContext acc = getStackAccessControlContext();
-        if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
-            return AccessController.doPrivileged(action, acc);
+        if (acc == null) {
+            return AccessController.doPrivileged(action);
         }
+        DomainCombiner dc = acc.getAssignedCombiner();
         return AccessController.doPrivileged(action, preserveCombiner(dc));
     }
 
@@ -386,11 +386,11 @@
     public static <T> T doPrivilegedWithCombiner
         (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
 
-        DomainCombiner dc = null;
         AccessControlContext acc = getStackAccessControlContext();
-        if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
-            return AccessController.doPrivileged(action, acc);
+        if (acc == null) {
+            return AccessController.doPrivileged(action);
         }
+        DomainCombiner dc = acc.getAssignedCombiner();
         return AccessController.doPrivileged(action, preserveCombiner(dc));
     }
 
@@ -417,7 +417,12 @@
         // perform 'combine' on the caller of doPrivileged,
         // even if the caller is from the bootclasspath
         ProtectionDomain[] pds = new ProtectionDomain[] {callerPd};
-        return new AccessControlContext(combiner.combine(pds, null), combiner);
+        if (combiner == null) {
+            return new AccessControlContext(pds);
+        } else {
+            return new AccessControlContext(combiner.combine(pds, null),
+                                            combiner);
+        }
     }