HHH-12233 : Fix NPE in CacheImpl.

HHH-12233 : Combine the 2 if statements.
This commit is contained in:
Frank Langelage 2018-01-21 13:52:07 +01:00 committed by Gail Badner
parent f7fa11a3f4
commit 25cde9d1c5
1 changed files with 10 additions and 11 deletions

View File

@ -402,17 +402,16 @@ public class CacheImpl implements CacheImplementor {
// which Map contents are added to getAllSecondLevelCacheRegions. // which Map contents are added to getAllSecondLevelCacheRegions.
// In addition, if there is a CollectionRegion and an EntityRegion with the same name, then we // In addition, if there is a CollectionRegion and an EntityRegion with the same name, then we
// want the EntityRegion to be in the Map that gets returned. // want the EntityRegion to be in the Map that gets returned.
final Map<String, Region> allCacheRegions = new HashMap<String, Region>( final Map<String, Region> allCacheRegions = new HashMap<String, Region>();
2 + queryCaches.size() + otherRegionMap.size() + naturalIdRegionMap.size() if ( settings.isQueryCacheEnabled() ) {
+ collectionRegionMap.size() + entityRegionMap.size() allCacheRegions.put( updateTimestampsCache.getRegion().getName(), updateTimestampsCache.getRegion() );
); allCacheRegions.put( queryCache.getRegion().getName(), queryCache.getRegion() );
allCacheRegions.put( updateTimestampsCache.getRegion().getName(), updateTimestampsCache.getRegion() ); // keys in queryCaches may not be equal to the Region names
allCacheRegions.put( queryCache.getRegion().getName(), queryCache.getRegion() ); // obtained from queryCaches values; we need to be sure we are adding
// keys in queryCaches may not be equal to the Region names // the actual QueryCache region name as the key in allCacheRegions.
// obtained from queryCaches values; we need to be sure we are adding for ( QueryCache queryCacheValue : queryCaches.values() ) {
// the actual QueryCache region name as the key in allCacheRegions. allCacheRegions.put( queryCacheValue.getRegion().getName(), queryCacheValue.getRegion() );
for ( QueryCache queryCacheValue : queryCaches.values() ) { }
allCacheRegions.put( queryCacheValue.getRegion().getName(), queryCacheValue.getRegion() );
} }
allCacheRegions.putAll( otherRegionMap ); allCacheRegions.putAll( otherRegionMap );
allCacheRegions.putAll( naturalIdRegionMap ); allCacheRegions.putAll( naturalIdRegionMap );