HADOOP-10826. Iteration on KeyProviderFactory.serviceLoader is thread-unsafe. (benoyantony viat tucu)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1612594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eac0701c96
commit
ab6af79126
@ -396,6 +396,9 @@ Trunk (Unreleased)
|
|||||||
HADOOP-10840. Fix OutOfMemoryError caused by metrics system in Azure File
|
HADOOP-10840. Fix OutOfMemoryError caused by metrics system in Azure File
|
||||||
System. (Shanyu Zhao via cnauroth)
|
System. (Shanyu Zhao via cnauroth)
|
||||||
|
|
||||||
|
HADOOP-10826. Iteration on KeyProviderFactory.serviceLoader is
|
||||||
|
thread-unsafe. (benoyantony viat tucu)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-7761. Improve the performance of raw comparisons. (todd)
|
HADOOP-7761. Improve the performance of raw comparisons. (todd)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
@ -47,6 +48,15 @@ public abstract KeyProvider createProvider(URI providerName,
|
|||||||
private static final ServiceLoader<KeyProviderFactory> serviceLoader =
|
private static final ServiceLoader<KeyProviderFactory> serviceLoader =
|
||||||
ServiceLoader.load(KeyProviderFactory.class);
|
ServiceLoader.load(KeyProviderFactory.class);
|
||||||
|
|
||||||
|
// Iterate through the serviceLoader to avoid lazy loading.
|
||||||
|
// Lazy loading would require synchronization in concurrent use cases.
|
||||||
|
static {
|
||||||
|
Iterator<KeyProviderFactory> iterServices = serviceLoader.iterator();
|
||||||
|
while (iterServices.hasNext()) {
|
||||||
|
iterServices.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static List<KeyProvider> getProviders(Configuration conf
|
public static List<KeyProvider> getProviders(Configuration conf
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
List<KeyProvider> result = new ArrayList<KeyProvider>();
|
List<KeyProvider> result = new ArrayList<KeyProvider>();
|
||||||
|
Loading…
Reference in New Issue
Block a user