Repository: hadoop Updated Branches: refs/heads/branch-2.8 7be52c9c7 -> c0e294ffc
HADOOP-10829. Iteration on CredentialProviderFactory.serviceLoader is thread-unsafe. Contributed by Benoy Antony and Rakesh R. (cherry picked from commit b82485d6fed2194bf0dc2eedfab7e226e30a7cf0) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c0e294ff Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c0e294ff Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c0e294ff Branch: refs/heads/branch-2.8 Commit: c0e294ffc82d611a64b352e3962bce9399ddbe5f Parents: 7be52c9 Author: Jitendra Pandey <[email protected]> Authored: Fri Jul 7 12:45:37 2017 -0700 Committer: Zhe Zhang <[email protected]> Committed: Tue Jul 25 09:04:49 2017 -0700 ---------------------------------------------------------------------- .../hadoop/security/alias/CredentialProviderFactory.java | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c0e294ff/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 3bb4f6d..1f5c8ec 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; @@ -47,6 +48,15 @@ public abstract class CredentialProviderFactory { private static final ServiceLoader<CredentialProviderFactory> serviceLoader = ServiceLoader.load(CredentialProviderFactory.class); + // 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: [email protected] For additional commands, e-mail: [email protected]
