Author: mthl
Date: Sun Oct 20 16:47:24 2019
New Revision: 1868665
URL:
http://svn.apache.org/viewvc?rev=1868665&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/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java?rev=1868665&r1=1868664&r2=1868665&view=diff==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ComponentContainer.java Sun Oct 20 16:47:24 2019
@@ -28,11 +28,11 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-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 java.util.stream.Collectors;
@@ -61,7 +61,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 {