Github user satishd commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2519#discussion_r162677211
  
    --- Diff: 
external/storm-autocreds/src/main/java/org/apache/storm/common/AbstractAutoCreds.java
 ---
    @@ -216,8 +216,7 @@ private void addTokensToUGI(Subject subject) {
                             for (Token<? extends TokenIdentifier> token : 
allTokens) {
                                 try {
                                     LOG.debug("Current user: {}", 
UserGroupInformation.getCurrentUser());
    -                                LOG.debug("Token from credential: {} / 
{}", token.toString(),
    -                                        
token.decodeIdentifier().getUser());
    +                                LOG.debug("Extracted Token from 
Credentials : {}", token);
    --- End diff --
    
    token.toString() will not print token.decodeIdentifier().getUser()) which 
may be useful in debugging. 
`UserGroupInformation.getCurrentUser().addToken(token)` ignores null tokens.
    Better to log and skip when `token` is null like below instead of changing 
the current log statements. 
    ```
        for (Token<? extends TokenIdentifier> token : allTokens) {
            try {
                if(token == null) {
                    LOG.debug("Ignoring null token");
                    continue;
                }
                LOG.debug("Current user: {}", 
UserGroupInformation.getCurrentUser());
                LOG.debug("Token from credential: {} / {}", token.toString(),
                        token.decodeIdentifier().getUser());
    
                UserGroupInformation.getCurrentUser().addToken(token);
                LOG.info("Added delegation tokens to UGI.");
            } catch (IOException e) {
                LOG.error("Exception while trying to add tokens to ugi", e);
            }
        }
    
    ```


---

Reply via email to