You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Haohui Mai (JIRA)" <ji...@apache.org> on 2014/04/10 02:55:19 UTC
[jira] [Created] (HADOOP-10487) Racy code in
UserGroupInformation#ensureInitialized()
Haohui Mai created HADOOP-10487:
-----------------------------------
Summary: Racy code in UserGroupInformation#ensureInitialized()
Key: HADOOP-10487
URL: https://issues.apache.org/jira/browse/HADOOP-10487
Project: Hadoop Common
Issue Type: Bug
Reporter: Haohui Mai
Assignee: Haohui Mai
UserGroupInformation#ensureInitialized() uses the double-check-locking pattern to reduce the synchronization cost:
{code}
private static void ensureInitialized() {
if (conf == null) {
synchronized(UserGroupInformation.class) {
if (conf == null) { // someone might have beat us
initialize(new Configuration(), false);
}
}
}
}
{code}
As [~tlipcon] pointed out in the original jira (HADOOP-9748). This pattern is incorrect. Please see more details in http://en.wikipedia.org/wiki/Double-checked_locking and http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
This jira proposes to use the static class holder pattern to do it correctly.
--
This message was sent by Atlassian JIRA
(v6.2#6252)