HHH-13645 Include a comment in the implementation about the design choice to not optimise for null values

This commit is contained in:
Sanne Grinovero 2019-09-30 10:35:14 +01:00
parent 00d25c1824
commit a92cd6c9b9
1 changed files with 4 additions and 2 deletions

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.stat.internal;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
@ -71,6 +69,10 @@ final class StatsNamedContainer<V> {
}
else {
final V v2 = function.apply( key );
//Occasionally a function might return null. We can't store a null in the CHM,
// so a placeholder would be required to implement that, but we prefer to just keep this
// situation as slightly sub-optimal so to not make the code more complex just to handle the exceptional case:
// null values are assumed to be rare enough for this not being worth it.
if ( v2 == null ) {
return null;
}