Author: mthl
Date: Sun Oct 20 16:51:09 2019
New Revision: 1868666
URL:
http://svn.apache.org/viewvc?rev=1868666&view=revLog:
Fixed: Use ‘ConcurrentHashMap’ to avoid ‘ConcurrentModificationException’
(OFBIZ-11258)
When trying to load components in their dependency order the
‘toBeLoadedComponents’ map is modified while being iterated over which
is not safe for non-concurrent maps.
Modified:
ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java
Modified: ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java?rev=1868666&r1=1868665&r2=1868666&view=diff==============================================================================
--- ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java (original)
+++ ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java Sun Oct 20 16:51:09 2019
@@ -26,11 +26,11 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ofbiz.base.component.ComponentConfig;
import org.apache.ofbiz.base.component.ComponentException;
@@ -59,7 +59,7 @@ public class ComponentContainer implemen
private String name;
private final AtomicBoolean loaded = new AtomicBoolean(false);
private final List<Classpath> componentsClassPath = new ArrayList<>();
- private static Map<String, List<ComponentConfig.DependsOnInfo>> toBeLoadedComponents = new HashMap<>();
+ private static Map<String, List<ComponentConfig.DependsOnInfo>> toBeLoadedComponents = new ConcurrentHashMap<>();
@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {