Skip to content

Commit

Permalink
Remove unused reference to filePermissionsCache
Browse files Browse the repository at this point in the history
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 elastic#31876
  • Loading branch information
Christoph Büscher committed Jul 10, 2018
1 parent 3189ef4 commit 661c024
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public RunAsPermission runAs() {
}

public static Builder builder(String... names) {
return new Builder(names, null);
}

public static Builder builder(String[] names, FieldPermissionsCache fieldPermissionsCache) {
return new Builder(names, fieldPermissionsCache);
return new Builder(names);
}

public static Builder builder(RoleDescriptor rd, FieldPermissionsCache fieldPermissionsCache) {
Expand Down Expand Up @@ -94,16 +90,13 @@ public static class Builder {
private ClusterPermission cluster = ClusterPermission.NONE;
private RunAsPermission runAs = RunAsPermission.NONE;
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.fieldPermissionsCache = fieldPermissionsCache;
}

private Builder(RoleDescriptor rd, @Nullable FieldPermissionsCache fieldPermissionsCache) {
this.names = new String[] { rd.getName() };
this.fieldPermissionsCache = fieldPermissionsCache;
if (rd.getClusterPrivileges().length == 0) {
cluster = ClusterPermission.NONE;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static Role buildRoleFromDescriptors(Set<RoleDescriptor> roleDescriptors,

final Set<String> clusterPrivs = clusterPrivileges.isEmpty() ? null : clusterPrivileges;
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))
.runAs(runAsPrivilege);
indicesPrivilegesMap.entrySet().forEach((entry) -> {
Expand Down

0 comments on commit 661c024

Please sign in to comment.