You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/02 08:53:41 UTC

[GitHub] [kafka] chia7712 commented on a change in pull request #10012: MINOR: Refactor return statement and log info

chia7712 commented on a change in pull request #10012:
URL: https://github.com/apache/kafka/pull/10012#discussion_r568422389



##########
File path: clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredValidatorCallbackHandler.java
##########
@@ -170,33 +170,31 @@ private void handleCallback(OAuthBearerValidatorCallback callback) {
                 .throwExceptionIfFailed();
         OAuthBearerValidationUtils.validateTimeConsistency(unsecuredJwt).throwExceptionIfFailed();
         OAuthBearerValidationUtils.validateScope(unsecuredJwt, requiredScope).throwExceptionIfFailed();
-        log.info("Successfully validated token with principal {}: {}", unsecuredJwt.principalName(),
-                unsecuredJwt.claims().toString());
+        if (log.isInfoEnabled()) {

Review comment:
       Is this condition check necessary? It is rare in code base.

##########
File path: clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredValidatorCallbackHandler.java
##########
@@ -170,33 +170,31 @@ private void handleCallback(OAuthBearerValidatorCallback callback) {
                 .throwExceptionIfFailed();
         OAuthBearerValidationUtils.validateTimeConsistency(unsecuredJwt).throwExceptionIfFailed();
         OAuthBearerValidationUtils.validateScope(unsecuredJwt, requiredScope).throwExceptionIfFailed();
-        log.info("Successfully validated token with principal {}: {}", unsecuredJwt.principalName(),
-                unsecuredJwt.claims().toString());
+        if (log.isInfoEnabled()) {
+            log.info("Successfully validated token with principal {}: {}", unsecuredJwt.principalName(), unsecuredJwt.claims());
+        }
         callback.token(unsecuredJwt);
     }
 
     private String principalClaimName() {
         String principalClaimNameValue = option(PRINCIPAL_CLAIM_NAME_OPTION);
-        String principalClaimName = principalClaimNameValue != null && !principalClaimNameValue.trim().isEmpty()
+        return principalClaimNameValue != null && !principalClaimNameValue.trim().isEmpty()

Review comment:
       How about adding a helper method to check both "null" and "empty"?




----------------------------------------------------------------
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.

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