MINOR: make sure all fiedls of o.p.k.s.a.Action are NOT null (#10764)

I'm migrating Ranger's kafka plugin from deprecated Authorizer (this is already removed by 976e78e) to new API (see https://issues.apache.org/jira/browse/RANGER-3231). The kafka plugin needs to take something from field resourcePattern but it does not know whether the field is nullable (or users need to add null check). I check all usages and I don't observe any null case.

Reviewers: Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
Chia-Ping Tsai 2021-05-28 13:41:52 +08:00 committed by GitHub
parent 5cbe6a7b09
commit a6f30945fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -31,27 +31,32 @@ public class Action {
private final boolean logIfAllowed;
private final boolean logIfDenied;
/**
* @param operation non-null operation being performed
* @param resourcePattern non-null resource pattern on which this action is being performed
*/
public Action(AclOperation operation,
ResourcePattern resourcePattern,
int resourceReferenceCount,
boolean logIfAllowed,
boolean logIfDenied) {
this.operation = operation;
this.resourcePattern = resourcePattern;
this.operation = Objects.requireNonNull(operation, "operation can't be null");
this.resourcePattern = Objects.requireNonNull(resourcePattern, "resourcePattern can't be null");
this.logIfAllowed = logIfAllowed;
this.logIfDenied = logIfDenied;
this.resourceReferenceCount = resourceReferenceCount;
}
/**
* Resource on which action is being performed.
* @return a non-null resource pattern on which this action is being performed
*/
public ResourcePattern resourcePattern() {
return resourcePattern;
}
/**
* Operation being performed.
*
* @return a non-null operation being performed
*/
public AclOperation operation() {
return operation;