commit | 7d25bd875a7ac349d476e4545d7c9e1e82b2700a | [log] [tgz] |
---|---|---|
author | Ali Alsuliman <ali.al.solaiman@gmail.com> | Thu May 23 05:45:03 2024 +0300 |
committer | Ali Alsuliman <ali.al.solaiman@gmail.com> | Thu May 23 14:28:14 2024 +0000 |
tree | 56dcd21a2a1cd71fc617e2e22a58d891b47b0c43 | |
parent | 7edce9eed01b5eb8e9dd101a6d817243c76ecb53 [diff] |
[ASTERIXDB-3405][EXT] Avoid ConcurrentModificationException in DatasourceFactoryProvider - user model changes: no - storage format changes: no - interface changes: no Details: Change-Id: Ic9dd2358ad093d3d59f838e85bc746d795638bb0 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18310 Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Tested-by: Ali Alsuliman <ali.al.solaiman@gmail.com> Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com> Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java index b0aded6..f35dce4 100644 --- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java +++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/DatasourceFactoryProvider.java
@@ -116,9 +116,7 @@ throw new NotImplementedException(); } - if (factories == null) { - initFactories(); - } + initFactories(); if (factories.containsKey(adaptorName)) { Map<String, Class<?>> formatClassMap = factories.get(adaptorName); @@ -134,7 +132,10 @@ } } - protected static void initFactories() throws AsterixException { + protected static synchronized void initFactories() throws AsterixException { + if (factories != null) { + return; + } factories = new HashMap<>(); ClassLoader cl = ParserFactoryProvider.class.getClassLoader(); final Charset encoding = StandardCharsets.UTF_8;