This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new a6f3094  MINOR: make sure all fiedls of o.p.k.s.a.Action are NOT null 
(#10764)
a6f3094 is described below

commit a6f30945facc7b77cd90ba4c4562932c8cd53f2d
Author: Chia-Ping Tsai <[email protected]>
AuthorDate: Fri May 28 13:41:52 2021 +0800

    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 <[email protected]>
---
 .../java/org/apache/kafka/server/authorizer/Action.java     | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/clients/src/main/java/org/apache/kafka/server/authorizer/Action.java 
b/clients/src/main/java/org/apache/kafka/server/authorizer/Action.java
index a62b7f0..60af34b 100644
--- a/clients/src/main/java/org/apache/kafka/server/authorizer/Action.java
+++ b/clients/src/main/java/org/apache/kafka/server/authorizer/Action.java
@@ -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;

Reply via email to