Преглед на файлове

HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1504874 13f79535-47bb-0310-9956-ffa450edef68
Daryn Sharp преди 12 години
родител
ревизия
aba335279a

+ 2 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -300,6 +300,8 @@ Release 2.3.0 - UNRELEASED
 
   OPTIMIZATIONS
 
+    HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)
+
   BUG FIXES
 
     HADOOP-9582. Non-existent file to "hadoop fs -conf" doesn't throw error

+ 6 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java

@@ -209,9 +209,13 @@ public class UserGroupInformation {
    * A method to initialize the fields that depend on a configuration.
    * Must be called before useKerberos or groups is used.
    */
-  private static synchronized void ensureInitialized() {
+  private static void ensureInitialized() {
     if (conf == null) {
-      initialize(new Configuration(), false);
+      synchronized(UserGroupInformation.class) {
+        if (conf == null) { // someone might have beat us
+          initialize(new Configuration(), false);
+        }
+      }
     }
   }