[ 
https://issues.apache.org/jira/browse/HADOOP-15593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16554020#comment-16554020
 ] 

Gabor Bota commented on HADOOP-15593:
-------------------------------------

Hi [~eyang], 
The first approach you've proposed won't work, because tgt.getEndTime() will 
throw an NPE.
My approach will be the following:

{code:java}
          long tgtEndTime = now;
          if (!tgt.isDestroyed()) {
            // As described in HADOOP-15593 we need to handle the case when
            // tgt.getEndTime() throws NPE because of JDK issue JDK-8147772
            // NPE is only possible if this issue is not fixed in the JDK
            // currently used
            try{
              tgtEndTime = tgt.getEndTime().getTime();
            } catch (NullPointerException npe) {
              LOG.warn("NPE thrown while getting KerberosTicket endTime. The "
                  + "endTime will be set to Time.now()");
            }
          }
{code}

This seems to me the most straightforward.

Hi [~xiaochen],
You are right, there's no need to check if {{tgt != null}}. 
The problem with the unit test for this is that KerberosTicket#getEndTime is 
final, so cannot be mocked to throw NPE without using powermock.
The best I can do now is to test the check for the isDestroyed flag.

> UserGroupInformation TGT renewer throws NPE
> -------------------------------------------
>
>                 Key: HADOOP-15593
>                 URL: https://issues.apache.org/jira/browse/HADOOP-15593
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: security
>    Affects Versions: 3.0.0
>            Reporter: Wei-Chiu Chuang
>            Assignee: Gabor Bota
>            Priority: Blocker
>         Attachments: HADOOP-15593.001.patch, HADOOP-15593.002.patch, 
> HADOOP-15593.003.patch
>
>
> Found the following NPE thrown in UGI tgt renewer. The NPE was thrown within 
> an exception handler so the original exception was hidden, though it's likely 
> caused by expired tgt.
> {noformat}
> 18/07/02 10:30:57 ERROR util.SparkUncaughtExceptionHandler: Uncaught 
> exception in thread Thread[TGT Renewer for [email protected],5,main]
> java.lang.NullPointerException
>         at 
> javax.security.auth.kerberos.KerberosTicket.getEndTime(KerberosTicket.java:482)
>         at 
> org.apache.hadoop.security.UserGroupInformation$1.run(UserGroupInformation.java:894)
>         at java.lang.Thread.run(Thread.java:748){noformat}
> Suspect it's related to [https://bugs.openjdk.java.net/browse/JDK-8154889].
> The relevant code was added in HADOOP-13590. File this jira to handle the 
> exception better.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to