Top Description Constructors Methods
reactor.netty5.internal.util

public final Class MapUtils

extends Object
Class Inheritance
Imports
java.util.Map, java.util.function.Function

It's a temporary workaround for Java 8 specific performance issue JDK-8161372 and this class should be removed once the Java 8 support is dropped.

Note

This utility class is for internal use only. It can be removed at any time.

Author
zimatars
Since
1.0.15

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <K, V> V

Returns:

the current (existing or computed) value associated with the specified key, or null if the computed value is null
computeIfAbsent
(Map<K, V>
the ConcurrentHashMap instance
map
,
K
key with which the specified value is to be associated
key
,
Function<K, V>
the function to compute a value
mappingFunction
)

ConcurrentHashMap.computeIfAbsent(k,v) locks when k is present.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MapUtilsback to summary
private MapUtils()

Method Detail

computeIfAbsentback to summary
public static <K, V> V computeIfAbsent(Map<K, V> map, K key, Function<K, V> mappingFunction)

ConcurrentHashMap.computeIfAbsent(k,v) locks when k is present. Add pre-screen before locking inside computeIfAbsent.

Note

This utility is not for a general purpose usage. Carefully consider the removal operations from the map. If you have many remove operations that are critical, do not use this pre-screening.

Parameters
map:Map<K, V>

the ConcurrentHashMap instance

key:K

key with which the specified value is to be associated

mappingFunction:Function<K, V>

the function to compute a value

Returns:V

the current (existing or computed) value associated with the specified key, or null if the computed value is null