HHH-13600 Avoid capturing lambdas in AbstractDomainDataRegion construction

This commit is contained in:
Sanne Grinovero 2019-08-28 11:15:09 +01:00
parent 3d715c0ae8
commit 86e498f4f7
1 changed files with 20 additions and 16 deletions

View File

@ -7,8 +7,9 @@
package org.hibernate.cache.spi.support; package org.hibernate.cache.spi.support;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.hibernate.cache.CacheException; import org.hibernate.cache.CacheException;
import org.hibernate.cache.cfg.spi.CollectionDataCachingConfig; import org.hibernate.cache.cfg.spi.CollectionDataCachingConfig;
@ -121,15 +122,16 @@ public abstract class AbstractDomainDataRegion extends AbstractRegion implements
private Map<NavigableRole, EntityDataAccess> generateEntityDataAccessMap( private Map<NavigableRole, EntityDataAccess> generateEntityDataAccessMap(
DomainDataRegionConfig regionConfig) { DomainDataRegionConfig regionConfig) {
if ( regionConfig.getEntityCaching().isEmpty() ) { final List<EntityDataCachingConfig> entityCaching = regionConfig.getEntityCaching();
if ( entityCaching.isEmpty() ) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
final Map<NavigableRole, EntityDataAccess> accessMap = new ConcurrentHashMap<>(); final Map<NavigableRole, EntityDataAccess> accessMap = new HashMap<>( entityCaching.size() );
for ( EntityDataCachingConfig entityAccessConfig : regionConfig.getEntityCaching() ) { for ( EntityDataCachingConfig entityAccessConfig : entityCaching ) {
accessMap.computeIfAbsent( accessMap.put(
entityAccessConfig.getNavigableRole(), entityAccessConfig.getNavigableRole(),
hierarchy -> generateEntityAccess( entityAccessConfig ) generateEntityAccess( entityAccessConfig )
); );
} }
@ -137,15 +139,16 @@ public abstract class AbstractDomainDataRegion extends AbstractRegion implements
} }
private Map<NavigableRole, NaturalIdDataAccess> generateNaturalIdDataAccessMap(DomainDataRegionConfig regionConfig) { private Map<NavigableRole, NaturalIdDataAccess> generateNaturalIdDataAccessMap(DomainDataRegionConfig regionConfig) {
if ( regionConfig.getNaturalIdCaching().isEmpty() ) { final List<NaturalIdDataCachingConfig> naturalIdCaching = regionConfig.getNaturalIdCaching();
if ( naturalIdCaching.isEmpty() ) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
final Map<NavigableRole, NaturalIdDataAccess> accessMap = new ConcurrentHashMap<>(); final Map<NavigableRole, NaturalIdDataAccess> accessMap = new HashMap<>( naturalIdCaching.size() );
for ( NaturalIdDataCachingConfig naturalIdAccessConfig : regionConfig.getNaturalIdCaching() ) { for ( NaturalIdDataCachingConfig naturalIdAccessConfig : naturalIdCaching ) {
accessMap.computeIfAbsent( accessMap.put(
naturalIdAccessConfig.getNavigableRole(), naturalIdAccessConfig.getNavigableRole(),
hierarchy -> generateNaturalIdAccess( naturalIdAccessConfig ) generateNaturalIdAccess( naturalIdAccessConfig )
); );
} }
@ -154,15 +157,16 @@ public abstract class AbstractDomainDataRegion extends AbstractRegion implements
private Map<NavigableRole, CollectionDataAccess> generateCollectionDataAccessMap( private Map<NavigableRole, CollectionDataAccess> generateCollectionDataAccessMap(
DomainDataRegionConfig regionConfig) { DomainDataRegionConfig regionConfig) {
if ( regionConfig.getCollectionCaching().isEmpty() ) { final List<CollectionDataCachingConfig> collectionCaching = regionConfig.getCollectionCaching();
if ( collectionCaching.isEmpty() ) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
final Map<NavigableRole, CollectionDataAccess> accessMap = new ConcurrentHashMap<>(); final Map<NavigableRole, CollectionDataAccess> accessMap = new HashMap<>( collectionCaching.size() );
for ( CollectionDataCachingConfig cachingConfig : regionConfig.getCollectionCaching() ) { for ( CollectionDataCachingConfig cachingConfig : collectionCaching ) {
accessMap.computeIfAbsent( accessMap.put(
cachingConfig.getNavigableRole(), cachingConfig.getNavigableRole(),
hierarchy -> generateCollectionAccess( cachingConfig ) generateCollectionAccess( cachingConfig )
); );
} }