Remove unused reference to filePermissionsCache (#31923)

Currently Role.Builder keeps a reference to the FieldPermissionsCache that is
passed into its constructors. This seems to be unused except for passing it on
to convertFromIndicesPrivileges() in the second ctor itself, but we don't need
to keep the internal reference in that case, so it can be removed.

Relates to #31876
This commit is contained in:
Christoph Büscher 2018-07-11 09:56:21 +02:00 committed by GitHub
parent c6666fc6cb
commit 4b8b831517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 10 deletions

View File

@ -55,11 +55,7 @@ public final class Role {
} }
public static Builder builder(String... names) { public static Builder builder(String... names) {
return new Builder(names, null); return new Builder(names);
}
public static Builder builder(String[] names, FieldPermissionsCache fieldPermissionsCache) {
return new Builder(names, fieldPermissionsCache);
} }
public static Builder builder(RoleDescriptor rd, FieldPermissionsCache fieldPermissionsCache) { public static Builder builder(RoleDescriptor rd, FieldPermissionsCache fieldPermissionsCache) {
@ -94,16 +90,13 @@ public final class Role {
private ClusterPermission cluster = ClusterPermission.NONE; private ClusterPermission cluster = ClusterPermission.NONE;
private RunAsPermission runAs = RunAsPermission.NONE; private RunAsPermission runAs = RunAsPermission.NONE;
private List<IndicesPermission.Group> groups = new ArrayList<>(); private List<IndicesPermission.Group> groups = new ArrayList<>();
private FieldPermissionsCache fieldPermissionsCache = null;
private Builder(String[] names, FieldPermissionsCache fieldPermissionsCache) { private Builder(String[] names) {
this.names = names; this.names = names;
this.fieldPermissionsCache = fieldPermissionsCache;
} }
private Builder(RoleDescriptor rd, @Nullable FieldPermissionsCache fieldPermissionsCache) { private Builder(RoleDescriptor rd, @Nullable FieldPermissionsCache fieldPermissionsCache) {
this.names = new String[] { rd.getName() }; this.names = new String[] { rd.getName() };
this.fieldPermissionsCache = fieldPermissionsCache;
if (rd.getClusterPrivileges().length == 0) { if (rd.getClusterPrivileges().length == 0) {
cluster = ClusterPermission.NONE; cluster = ClusterPermission.NONE;
} else { } else {

View File

@ -278,7 +278,7 @@ public class CompositeRolesStore extends AbstractComponent {
final Set<String> clusterPrivs = clusterPrivileges.isEmpty() ? null : clusterPrivileges; final Set<String> clusterPrivs = clusterPrivileges.isEmpty() ? null : clusterPrivileges;
final Privilege runAsPrivilege = runAs.isEmpty() ? Privilege.NONE : new Privilege(runAs, runAs.toArray(Strings.EMPTY_ARRAY)); final Privilege runAsPrivilege = runAs.isEmpty() ? Privilege.NONE : new Privilege(runAs, runAs.toArray(Strings.EMPTY_ARRAY));
Role.Builder builder = Role.builder(roleNames.toArray(new String[roleNames.size()]), fieldPermissionsCache) Role.Builder builder = Role.builder(roleNames.toArray(new String[roleNames.size()]))
.cluster(ClusterPrivilege.get(clusterPrivs)) .cluster(ClusterPrivilege.get(clusterPrivs))
.runAs(runAsPrivilege); .runAs(runAsPrivilege);
indicesPrivilegesMap.entrySet().forEach((entry) -> { indicesPrivilegesMap.entrySet().forEach((entry) -> {