HADOOP-14195. CredentialProviderFactory$getProviders is not thread-safe. Contributed by Vihang Karajgaonkar.
(cherry picked from commit 128015584d
)
This commit is contained in:
parent
47d3c29e30
commit
a92f654aa2
|
@ -54,6 +54,9 @@ public abstract class CredentialProviderFactory {
|
||||||
try {
|
try {
|
||||||
URI uri = new URI(path);
|
URI uri = new URI(path);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
// Iterate serviceLoader in a synchronized block since
|
||||||
|
// serviceLoader iterator is not thread-safe.
|
||||||
|
synchronized (serviceLoader) {
|
||||||
for (CredentialProviderFactory factory : serviceLoader) {
|
for (CredentialProviderFactory factory : serviceLoader) {
|
||||||
CredentialProvider kp = factory.createProvider(uri, conf);
|
CredentialProvider kp = factory.createProvider(uri, conf);
|
||||||
if (kp != null) {
|
if (kp != null) {
|
||||||
|
@ -62,6 +65,7 @@ public abstract class CredentialProviderFactory {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new IOException("No CredentialProviderFactory for " + uri + " in " +
|
throw new IOException("No CredentialProviderFactory for " + uri + " in " +
|
||||||
CREDENTIAL_PROVIDER_PATH);
|
CREDENTIAL_PROVIDER_PATH);
|
||||||
|
|
Loading…
Reference in New Issue