hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzh...@apache.org
Subject hadoop git commit: HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang Karajgaonkar.
Date Thu, 23 Mar 2017 20:58:41 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.8 47d3c29e3 -> a92f654aa


HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang
Karajgaonkar.

(cherry picked from commit 128015584d69492806fd1700c8f840d78aa9c729)


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

Branch: refs/heads/branch-2.8
Commit: a92f654aa2859dd962b6d75f4b25a7f8344cc7aa
Parents: 47d3c29
Author: John Zhuge <jzhuge@apache.org>
Authored: Thu Mar 23 13:58:11 2017 -0700
Committer: John Zhuge <jzhuge@apache.org>
Committed: Thu Mar 23 13:58:11 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a92f654a/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 36b4ecb..3bb4f6d 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
@@ -54,12 +54,16 @@ public abstract class CredentialProviderFactory {
       try {
         URI uri = new URI(path);
         boolean found = false;
-        for(CredentialProviderFactory factory: serviceLoader) {
-          CredentialProvider kp = factory.createProvider(uri, conf);
-          if (kp != null) {
-            result.add(kp);
-            found = true;
-            break;
+        // Iterate serviceLoader in a synchronized block since
+        // serviceLoader iterator is not thread-safe.
+        synchronized (serviceLoader) {
+          for (CredentialProviderFactory factory : serviceLoader) {
+            CredentialProvider kp = factory.createProvider(uri, conf);
+            if (kp != null) {
+              result.add(kp);
+              found = true;
+              break;
+            }
           }
         }
         if (!found) {


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


Mime
View raw message