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

eBugs commented on YARN-9533:
-----------------------------

After looking at the related code, I found that this is similar to YARN-9534.

 

Although switching to a completely new exception is a bad idea. *Is it better 
to wrap the InterruptedException?* In this way, the inner stack trace is 
included, and users can know which method is interrupted by looking at the 
stack trace. Another benefit of wrapping the cause exception is that if callers 
want to perform accurate exception handling, they can extract the cause 
exception instead of parsing the error message to understand want's really 
going on.

 

I also found a similar code in one of checkRetryWithSleep()'s callers, 
TimelineV2ClientImpl$TimelineEntityDispatcher.dispatchEntities(). The 
InterruptedException is wrapped here.:
{code:java}
public void dispatchEntities(boolean sync,
    TimelineEntity[] entitiesTobePublished, boolean subappwrite)
    throws YarnException {
  ...
  EntitiesHolder entitiesHolder =
      new EntitiesHolder(entities, sync, subappwrite); // <-- This eventually 
calls checkRetryWithSleep()
  try {
    timelineEntityQueue.put(entitiesHolder);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new YarnException(
        "Failed while adding entity to the queue for publishing", e); // <-- 
Here, YarnException wraps InterruptedException
  }
}{code}

> TimelineV2ClientImpl.checkRetryWithSleep() throws a YarnException when 
> interrupted
> ----------------------------------------------------------------------------------
>
>                 Key: YARN-9533
>                 URL: https://issues.apache.org/jira/browse/YARN-9533
>             Project: Hadoop YARN
>          Issue Type: Bug
>            Reporter: eBugs
>            Priority: Minor
>
> Dear YARN developers, we are developing a tool to detect exception-related 
> bugs in Java. Our prototype has spotted the following throw statement whose 
> exception class and error message indicate different error conditions. 
>   
> Version: Hadoop-3.1.2 
> File: 
> HADOOP-ROOT/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineV2ClientImpl.java
> Line: 274
> {code:java}
> try {
>   Thread.sleep(this.serviceRetryInterval);
> } catch (InterruptedException ex) {
>   Thread.currentThread().interrupt();
>   throw new YarnException("Interrupted while retrying to connect to ATS");
> }{code}
>  
> The exception is triggered when {{checkRetryWithSleep()}} is interrupted. 
> However, throwing a {{YarnException}} is too general and makes accurate 
> exception handling more difficult. Throwing an {{InterruptedIOException}} or 
> wrapping the {{InterruptedException}} could be more accurate here.



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