hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From inigo...@apache.org
Subject [09/50] [abbrv] hadoop git commit: HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang Karajgaonkar.
Date Tue, 28 Mar 2017 21:25:32 GMT
HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang
Karajgaonkar.


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

Branch: refs/heads/HDFS-10467
Commit: 128015584d69492806fd1700c8f840d78aa9c729
Parents: d35e79a
Author: John Zhuge <jzhuge@apache.org>
Authored: Thu Mar 23 13:56:19 2017 -0700
Committer: John Zhuge <jzhuge@apache.org>
Committed: Thu Mar 23 13:57:08 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/hadoop/blob/12801558/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 3c3f79f..d1e3eb5 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
@@ -56,12 +56,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