hadoop-yarn-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tao Jie (JIRA)" <j...@apache.org>
Subject [jira] [Created] (YARN-6236) Move lock() out of try-block in FairScheduler
Date Mon, 27 Feb 2017 06:21:45 GMT
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-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-issues-help@hadoop.apache.org


Mime
View raw message