You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2017/07/11 00:54:34 UTC

hadoop git commit: HADOOP-10829. Iteration on CredentialProviderFactory.serviceLoader is thread-unsafe. Contributed by Benoy Antony and Rakesh R.

Repository: hadoop
Updated Branches:
  refs/heads/trunk 5496a34c0 -> f1efa14fc


HADOOP-10829. Iteration on CredentialProviderFactory.serviceLoader is thread-unsafe. Contributed by Benoy Antony and Rakesh R.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f1efa14f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f1efa14f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f1efa14f

Branch: refs/heads/trunk
Commit: f1efa14fc676641fa15c11d3147e3ad948b084e9
Parents: 5496a34
Author: Jitendra Pandey <ji...@apache.org>
Authored: Fri Jul 7 12:45:37 2017 -0700
Committer: Jitendra Pandey <ji...@apache.org>
Committed: Mon Jul 10 17:48:27 2017 -0700

----------------------------------------------------------------------
 .../hadoop/security/alias/CredentialProviderFactory.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f1efa14f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java
index d1e3eb5..1b2ac41 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.ServiceLoader;
 
@@ -49,6 +50,15 @@ public abstract class CredentialProviderFactory {
       ServiceLoader.load(CredentialProviderFactory.class,
           CredentialProviderFactory.class.getClassLoader());
 
+  // Iterate through the serviceLoader to avoid lazy loading.
+  // Lazy loading would require synchronization in concurrent use cases.
+  static {
+    Iterator<CredentialProviderFactory> iterServices = serviceLoader.iterator();
+    while (iterServices.hasNext()) {
+      iterServices.next();
+    }
+  }
+
   public static List<CredentialProvider> getProviders(Configuration conf
                                                ) throws IOException {
     List<CredentialProvider> result = new ArrayList<CredentialProvider>();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org