HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang Karajgaonkar.
This commit is contained in:
parent
d35e79abc2
commit
128015584d
|
@ -56,6 +56,9 @@ public abstract class CredentialProviderFactory {
|
|||
try {
|
||||
URI uri = new URI(path);
|
||||
boolean found = false;
|
||||
// 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) {
|
||||
|
@ -64,6 +67,7 @@ public abstract class CredentialProviderFactory {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
throw new IOException("No CredentialProviderFactory for " + uri + " in " +
|
||||
CREDENTIAL_PROVIDER_PATH);
|
||||
|
|
Loading…
Reference in New Issue