Skip to content

Commit 183cebc

Browse files
committed
Deterministic order
1 parent aae2ace commit 183cebc

File tree

1 file changed

+7
-5
lines changed
  • x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege

1 file changed

+7
-5
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.Collection;
4949
import java.util.Collections;
5050
import java.util.HashSet;
51+
import java.util.LinkedHashSet;
5152
import java.util.Locale;
5253
import java.util.Map;
5354
import java.util.Objects;
@@ -377,7 +378,7 @@ private static Set<IndexPrivilege> resolve(Set<String> name) {
377378
actions
378379
);
379380
assertNamesMatch(name, combined);
380-
return Set.copyOf(combined);
381+
return Collections.unmodifiableSet(combined);
381382
}
382383

383384
private static Set<IndexPrivilege> combineIndexPrivileges(
@@ -397,13 +398,14 @@ private static Set<IndexPrivilege> combineIndexPrivileges(
397398
return Set.of(union(allSelectorAccessPrivileges, actions, IndexComponentSelectorPredicate.ALL));
398399
}
399400

400-
final Set<IndexPrivilege> combined = new HashSet<>();
401-
if (false == failuresSelectorAccessPrivileges.isEmpty()) {
402-
combined.add(union(failuresSelectorAccessPrivileges, Set.of(), IndexComponentSelectorPredicate.FAILURES));
403-
}
401+
// linked hash set to preserve order across selectors
402+
final Set<IndexPrivilege> combined = new LinkedHashSet<>();
404403
if (false == dataSelectorAccessPrivileges.isEmpty() || false == actions.isEmpty()) {
405404
combined.add(union(dataSelectorAccessPrivileges, actions, IndexComponentSelectorPredicate.DATA));
406405
}
406+
if (false == failuresSelectorAccessPrivileges.isEmpty()) {
407+
combined.add(union(failuresSelectorAccessPrivileges, Set.of(), IndexComponentSelectorPredicate.FAILURES));
408+
}
407409
return combined;
408410
}
409411

0 commit comments

Comments
 (0)