You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-dev@hadoop.apache.org by "Tao Jie (JIRA)" <ji...@apache.org> on 2017/02/27 06:21:45 UTC

[jira] [Created] (YARN-6236) Move lock() out of try-block in FairScheduler

Tao Jie created YARN-6236:
-----------------------------

             Summary: Move lock() out of try-block in FairScheduler
                 Key: YARN-6236
                 URL: https://issues.apache.org/jira/browse/YARN-6236
             Project: Hadoop YARN
          Issue Type: Bug
            Reporter: Tao Jie
            Assignee: Tao Jie


As discussed in YARN-6215, {{read/writeLock.lock()}} inside the try-block is widely used in existing code, especially in FairScheduler.java, eg:
{code}
  public ResourceWeights getAppWeight(FSAppAttempt app) {
    try {
      readLock.lock();
      ...
      ...
      return resourceWeights;
    } finally {
      readLock.unlock();
    }
  }
{code}
However in the best practice, {{lock()}} should be called outside of the try-block. In case of exception happens on {{lock()}} itself, {{unlock()}} in finally should not be invoked.
We'd better to move {{lock()}} out of try-block.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-dev-help@hadoop.apache.org