This is the current implementation in stdlib: ```p...
# stdlib
d
This is the current implementation in stdlib:
Copy code
public inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {
    // Do not use computeIfAbsent on JVM8 as it would change locking behavior
    return this.get(key)
            ?: defaultValue().let { default -> this.putIfAbsent(key, default) ?: default }
}
The problem is that if
defaultValue
returns
null
,
putIfAbsent
will crash with an NPE... is there a way to ensure that it should not be able to receive nulls?
🤔 1