You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "kumaab (via GitHub)" <gi...@apache.org> on 2024/12/18 08:51:16 UTC

[PR] RANGER-5039: checkstyle compliance updates - plugin-kafka module [ranger]

kumaab opened a new pull request, #463:
URL: https://github.com/apache/ranger/pull/463

     ## What changes were proposed in this pull request?
   
     Updated `plugin-kafka module` sources to comply with the check-style requirements.
   
   
     ## How was this patch tested?
     `mvn clean verify` on local machine.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-5039: checkstyle compliance updates - plugin-kafka module [ranger]

Posted by "mneethiraj (via GitHub)" <gi...@apache.org>.
mneethiraj commented on code in PR #463:
URL: https://github.com/apache/ranger/pull/463#discussion_r1890500077


##########
plugin-kafka/src/main/java/org/apache/ranger/authorization/kafka/authorizer/RangerKafkaAuditHandler.java:
##########
@@ -33,80 +32,73 @@
 public class RangerKafkaAuditHandler extends RangerDefaultAuditHandler {
     private static final Logger LOG = LoggerFactory.getLogger(RangerKafkaAuditHandler.class);
 
-    private AuthzAuditEvent auditEvent      = null;
+    private AuthzAuditEvent auditEvent;
 
-    public RangerKafkaAuditHandler(){
+    public RangerKafkaAuditHandler() {
     }
 
     @Override
     public void processResult(RangerAccessResult result) {
         // If Cluster Resource Level Topic Creation is not Allowed we don't audit.
         // Subsequent call from Kafka for Topic Creation at Topic resource Level will be audited.
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("==> RangerKafkaAuditHandler.processResult()");
-        }
+        LOG.trace("==> RangerKafkaAuditHandler.processResult()");
+
         if (!isAuditingNeeded(result)) {
             return;
         }
+
         auditEvent = super.getAuthzEvents(result);
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("<== RangerKafkaAuditHandler.processResult()");
-        }
+
+        LOG.trace("<== RangerKafkaAuditHandler.processResult()");
     }
+
     @Override
     public void processResults(Collection<RangerAccessResult> results) {
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("==> RangerKafkaAuditHandler.processResults(" + results + ")");
-        }
-        if (results!=null){
-            for(RangerAccessResult res: results){
+        LOG.trace("==> RangerKafkaAuditHandler.processResults({})", results);
+
+        if (results != null) {
+            for (RangerAccessResult res : results) {
                 processResult(res);
                 flushAudit();
             }
         }
 
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("<== RangerKafkaAuditHandler.processResults(" + results + ")");
-        }
+        LOG.trace("<== RangerKafkaAuditHandler.processResults({})", results);
     }
 
+    public void flushAudit() {
+        LOG.trace("==> RangerKafkaAuditHandler.flushAudit(AuditEvent: {})", auditEvent);
 
-    private boolean isAuditingNeeded(final RangerAccessResult result) {
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("==> RangerKafkaAuditHandler.isAuditingNeeded()");
+        if (auditEvent != null) {
+            super.logAuthzAudit(auditEvent);
         }
-        boolean ret = true;
-        boolean 			    isAllowed = result.getIsAllowed();
-        RangerAccessRequest       request = result.getAccessRequest();
-        RangerAccessResourceImpl resource = (RangerAccessResourceImpl) request.getResource();
-        String resourceName 			  = (String) resource.getValue(RangerKafkaAuthorizer.KEY_CLUSTER);
+
+        LOG.trace("<== RangerKafkaAuditHandler.flushAudit()");
+    }
+
+    private boolean isAuditingNeeded(final RangerAccessResult result) {
+        LOG.trace("==> RangerKafkaAuditHandler.isAuditingNeeded()");
+
+        boolean                  ret          = true;
+        boolean                  isAllowed    = result.getIsAllowed();
+        RangerAccessRequest      request      = result.getAccessRequest();
+        RangerAccessResourceImpl resource     = (RangerAccessResourceImpl) request.getResource();
+        String                   resourceName = (String) resource.getValue(RangerKafkaAuthorizer.KEY_CLUSTER);
+
         if (resourceName != null) {
             if (request.getAccessType().equalsIgnoreCase(RangerKafkaAuthorizer.ACCESS_TYPE_CREATE) && !isAllowed) {
                 ret = false;
             }
         }
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("RangerKafkaAuditHandler: isAuditingNeeded()");
-            LOG.trace("request:"+request);
-            LOG.trace("resource:"+resource);
-            LOG.trace("resourceName:"+resourceName);
-            LOG.trace("request.getAccessType():"+request.getAccessType());
-            LOG.trace("isAllowed:"+isAllowed);
-            LOG.trace("ret="+ret);
-            LOG.trace("<== RangerKafkaAuditHandler.isAuditingNeeded() = "+ret+" for result="+result);
-        }
-        return ret;
-    }
 
-    public void flushAudit() {
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("==> RangerKafkaAuditHandler.flushAudit(" + "AuditEvent: " + auditEvent+")");
-        }
-        if (auditEvent != null) {
-            super.logAuthzAudit(auditEvent);
-        }
-        if(LOG.isTraceEnabled()) {
-            LOG.trace("<== RangerKafkaAuditHandler.flushAudit()");
-        }
+        LOG.trace("RangerKafkaAuditHandler: isAuditingNeeded()");

Review Comment:
   Surrounding these 8 `LOG.trace()` calls with `LOG.isTraceEnabled()` will replace 8 calls with 1 when trace level logging is not enabled (by default).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-5039: checkstyle compliance updates - plugin-kafka module [ranger]

Posted by "kumaab (via GitHub)" <gi...@apache.org>.
kumaab merged PR #463:
URL: https://github.com/apache/ranger/pull/463


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org