[ https://issues.apache.org/jira/browse/YARN-6236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15885267#comment-15885267 ]
Tao Jie commented on YARN-6236: ------------------------------- Checked files in fair folder by {{grep -R "Lock.lock()" -A 1 -B 1 ./}} and uploaded the patch. [~kasha], would you give it a review? > 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 > Components: fairscheduler > Reporter: Tao Jie > Assignee: Tao Jie > Attachments: YARN-6236.001.patch > > > 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-unsubscr...@hadoop.apache.org For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org