Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-10487

Racy code in UserGroupInformation#ensureInitialized()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      UserGroupInformation#ensureInitialized() uses the double-check-locking pattern to reduce the synchronization cost:

        private static void ensureInitialized() {
          if (conf == null) {
            synchronized(UserGroupInformation.class) {
              if (conf == null) { // someone might have beat us
                initialize(new Configuration(), false);
              }
            }
          }
        }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              wheat9 Haohui Mai
              wheat9 Haohui Mai
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: