HHH-13645 : StatsNamedContainer#getOrCompute throws NullPointerException when computed value is null

This commit is contained in:
Gail Badner 2019-09-27 15:32:25 -07:00 committed by Sanne Grinovero
parent a7d9d75e94
commit 7b104e5ded
1 changed files with 9 additions and 4 deletions

View File

@ -54,6 +54,10 @@ final class StatsNamedContainer<V> {
} }
else { else {
final V v2 = function.apply( key ); final V v2 = function.apply( key );
if ( v2 == null ) {
return null;
}
else {
final V v3 = map.putIfAbsent( key, v2 ); final V v3 = map.putIfAbsent( key, v2 );
if ( v3 == null ) { if ( v3 == null ) {
return v2; return v2;
@ -63,6 +67,7 @@ final class StatsNamedContainer<V> {
} }
} }
} }
}
public V get(final String key) { public V get(final String key) {
return map.get( key ); return map.get( key );