src/share/classes/javax/security/auth/Subject.java

Print this page
rev 7932 : 8021591: Additional explicit null checks
Reviewed-by: psandoz, martin, alanb


1169                     next = java.security.AccessController.doPrivileged
1170                         (new java.security.PrivilegedAction<E>() {
1171                         public E run() {
1172                             return e.next();
1173                         }
1174                     });
1175                 }
1176 
1177                 if (next == null) {
1178                     if (o == null) {
1179                         return true;
1180                     }
1181                 } else if (next.equals(o)) {
1182                     return true;
1183                 }
1184             }
1185             return false;
1186         }
1187 
1188         public boolean removeAll(Collection<?> c) {
1189 
1190             boolean modified = false;
1191             final Iterator<E> e = iterator();
1192             while (e.hasNext()) {
1193                 E next;
1194                 if (which != Subject.PRIV_CREDENTIAL_SET) {
1195                     next = e.next();
1196                 } else {
1197                     next = java.security.AccessController.doPrivileged
1198                         (new java.security.PrivilegedAction<E>() {
1199                         public E run() {
1200                             return e.next();
1201                         }
1202                     });
1203                 }
1204 
1205                 Iterator<?> ce = c.iterator();
1206                 while (ce.hasNext()) {
1207                     Object o = ce.next();
1208                     if (next == null) {
1209                         if (o == null) {
1210                             e.remove();
1211                             modified = true;
1212                             break;
1213                         }
1214                     } else if (next.equals(o)) {
1215                         e.remove();
1216                         modified = true;
1217                         break;
1218                     }
1219                 }
1220             }
1221             return modified;
1222         }
1223 
1224         public boolean retainAll(Collection<?> c) {
1225 
1226             boolean modified = false;
1227             boolean retain = false;
1228             final Iterator<E> e = iterator();
1229             while (e.hasNext()) {
1230                 retain = false;
1231                 E next;
1232                 if (which != Subject.PRIV_CREDENTIAL_SET) {
1233                     next = e.next();
1234                 } else {
1235                     next = java.security.AccessController.doPrivileged
1236                         (new java.security.PrivilegedAction<E>() {
1237                         public E run() {
1238                             return e.next();
1239                         }
1240                     });
1241                 }
1242 
1243                 Iterator<?> ce = c.iterator();
1244                 while (ce.hasNext()) {
1245                     Object o = ce.next();




1169                     next = java.security.AccessController.doPrivileged
1170                         (new java.security.PrivilegedAction<E>() {
1171                         public E run() {
1172                             return e.next();
1173                         }
1174                     });
1175                 }
1176 
1177                 if (next == null) {
1178                     if (o == null) {
1179                         return true;
1180                     }
1181                 } else if (next.equals(o)) {
1182                     return true;
1183                 }
1184             }
1185             return false;
1186         }
1187 
1188         public boolean removeAll(Collection<?> c) {
1189             Objects.requireNonNull(c);
1190             boolean modified = false;
1191             final Iterator<E> e = iterator();
1192             while (e.hasNext()) {
1193                 E next;
1194                 if (which != Subject.PRIV_CREDENTIAL_SET) {
1195                     next = e.next();
1196                 } else {
1197                     next = java.security.AccessController.doPrivileged
1198                         (new java.security.PrivilegedAction<E>() {
1199                         public E run() {
1200                             return e.next();
1201                         }
1202                     });
1203                 }
1204 
1205                 Iterator<?> ce = c.iterator();
1206                 while (ce.hasNext()) {
1207                     Object o = ce.next();
1208                     if (next == null) {
1209                         if (o == null) {
1210                             e.remove();
1211                             modified = true;
1212                             break;
1213                         }
1214                     } else if (next.equals(o)) {
1215                         e.remove();
1216                         modified = true;
1217                         break;
1218                     }
1219                 }
1220             }
1221             return modified;
1222         }
1223 
1224         public boolean retainAll(Collection<?> c) {
1225             Objects.requireNonNull(c);
1226             boolean modified = false;
1227             boolean retain = false;
1228             final Iterator<E> e = iterator();
1229             while (e.hasNext()) {
1230                 retain = false;
1231                 E next;
1232                 if (which != Subject.PRIV_CREDENTIAL_SET) {
1233                     next = e.next();
1234                 } else {
1235                     next = java.security.AccessController.doPrivileged
1236                         (new java.security.PrivilegedAction<E>() {
1237                         public E run() {
1238                             return e.next();
1239                         }
1240                     });
1241                 }
1242 
1243                 Iterator<?> ce = c.iterator();
1244                 while (ce.hasNext()) {
1245                     Object o = ce.next();