Michael Kublin has uploaded a new change for review. Change subject: core: Fixing possible ConcurrentModificationException ......................................................................
core: Fixing possible ConcurrentModificationException The following class is used all around the code, the map is shared and should be thread safe Change-Id: I3ea0bc0cfd3452ff71ddb4ed9f9b1939b0f76238 Signed-off-by: Michael Kublin <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/EnumUtils.java 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/36/8436/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/EnumUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/EnumUtils.java index ffa7686..41bded6 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/EnumUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/EnumUtils.java @@ -2,10 +2,12 @@ import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; public class EnumUtils { - private static Map<Class<?>, Map> cacheEnumValuesInCapitalLetters = new HashMap<Class<?>, Map>(); + private final static ConcurrentMap<Class<?>, Map> cacheEnumValuesInCapitalLetters = new ConcurrentHashMap<Class<?>, Map>(); public static <E extends Enum<E>> E valueOf(Class<E> c, String name, boolean ignorecase) { // trim any leading or trailing spaces from the name @@ -29,7 +31,7 @@ for (E e : universe) { map.put(e.name().toUpperCase(), e); } - cacheEnumValuesInCapitalLetters.put(c, map); + cacheEnumValuesInCapitalLetters.putIfAbsent(c, map); } E result = map.get(name.toUpperCase()); -- To view, visit http://gerrit.ovirt.org/8436 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3ea0bc0cfd3452ff71ddb4ed9f9b1939b0f76238 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Michael Kublin <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
