Class CmsNullIgnoringConcurrentMap<K,V>
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
Map<K,
V>
The point of this is the following: Often, HashMaps in older code are accessed concurrently by multiple threads. When these threads modify the map concurrently, an infinite loop may occur due to the standard HashMap implementation. But sometimes we can't just replace the HashMap with a ConcurrentHashMap because that class doesn't allow null values and we don't always know for certain whether null values are used or not. But if we don't care about the distinction about null values and entries not being present, we can use this map class which will just log an error and remove the entry when trying to set a null value. NOTE: Currently this wrapper does *not* check value modifications made to entries returned by entrySet!
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCreates a new instance.CmsNullIgnoringConcurrentMap
(Map<K, V> otherMap) Creates a new instance from another map. -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CmsNullIgnoringConcurrentMap
public CmsNullIgnoringConcurrentMap()Creates a new instance. -
CmsNullIgnoringConcurrentMap
Creates a new instance from another map.- Parameters:
otherMap
- the other map
-
-
Method Details
-
clear
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - See Also:
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V> - See Also:
-
entrySet
-
equals
-
get
-
hashCode
-
isEmpty
-
keySet
-
put
Sets the given map value for the given key, unless either of them is null.If the value is null,
-
putAll
-
remove
-
size
-
toString
-
values
-