Javadoc from ConcurrentHashMap#computeIfAbsent says
The computation should be short and simple, and must not attempt to update any other mappings of this map.
But, from what I see, using remove() and clear() methods inside mappingFunction works fine. For example this
Key element = elements.computeIfAbsent(key, e -> {
if (usages.size() == maxSize) {
elements.remove(oldest);
}
return loader.load(key);
});
What bad consequences of using remove() method inside mappingFunction could be?