|
39 | 39 | import java.util.Objects; |
40 | 40 | import java.util.Set; |
41 | 41 | import java.util.concurrent.ConcurrentHashMap; |
42 | | -import java.util.concurrent.atomic.AtomicInteger; |
43 | 42 | import java.util.function.BiPredicate; |
44 | 43 | import java.util.function.Predicate; |
45 | 44 | import java.util.function.Supplier; |
@@ -443,25 +442,27 @@ public IndicesAccessControl authorize( |
443 | 442 | FieldPermissionsCache fieldPermissionsCache |
444 | 443 | ) { |
445 | 444 | // Short circuit if the indicesPermission allows all access to every index |
446 | | - if (Arrays.stream(groups).anyMatch(Group::isTotal)) { |
447 | | - return IndicesAccessControl.allowAll(); |
| 445 | + for (Group group : groups) { |
| 446 | + if (group.isTotal()) { |
| 447 | + return IndicesAccessControl.allowAll(); |
| 448 | + } |
448 | 449 | } |
449 | 450 |
|
450 | 451 | final Map<String, IndexResource> resources = Maps.newMapWithExpectedSize(requestedIndicesOrAliases.size()); |
451 | | - final AtomicInteger totalResourceCountHolder = new AtomicInteger(0); |
| 452 | + int totalResourceCount = 0; |
452 | 453 |
|
453 | 454 | for (String indexOrAlias : requestedIndicesOrAliases) { |
454 | 455 | final IndexResource resource = new IndexResource(indexOrAlias, lookup.get(indexOrAlias)); |
455 | 456 | resources.put(resource.name, resource); |
456 | | - totalResourceCountHolder.getAndAdd(resource.size()); |
| 457 | + totalResourceCount += resource.size(); |
457 | 458 | } |
458 | 459 |
|
459 | 460 | final boolean overallGranted = isActionGranted(action, resources); |
460 | | - |
| 461 | + final int finalTotalResourceCount = totalResourceCount; |
461 | 462 | final Supplier<Map<String, IndicesAccessControl.IndexAccessControl>> indexPermissions = () -> buildIndicesAccessControl( |
462 | 463 | action, |
463 | 464 | resources, |
464 | | - totalResourceCountHolder.get(), |
| 465 | + finalTotalResourceCount, |
465 | 466 | fieldPermissionsCache |
466 | 467 | ); |
467 | 468 |
|
|
0 commit comments