HHH-12529 - Some StatisticsImpl methods throw an exception instead of returning null
This commit is contained in:
parent
e2ac4eb22f
commit
26bf33abdc
|
@ -625,10 +625,12 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
return l2CacheStatsMap.computeIfAbsent(
|
return l2CacheStatsMap.computeIfAbsent(
|
||||||
regionName,
|
regionName,
|
||||||
s -> {
|
s -> {
|
||||||
final Region region = sessionFactory.getCache().getRegion( regionName );
|
Region region = sessionFactory.getCache().getRegion( regionName );
|
||||||
|
|
||||||
if ( region == null ) {
|
if ( region == null ) {
|
||||||
throw new IllegalArgumentException( "Unknown cache region : " + regionName );
|
// this is the pre-5.3 behavior. and since this is a pre-5.3 method it should behave consistently
|
||||||
|
// NOTE that this method is deprecated
|
||||||
|
region = sessionFactory.getCache().getQueryResultsCache( regionName ).getRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CacheRegionStatisticsImpl( region );
|
return new CacheRegionStatisticsImpl( region );
|
||||||
|
@ -638,6 +640,9 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CacheRegionStatisticsImpl getSecondLevelCacheStatistics(String regionName) {
|
public CacheRegionStatisticsImpl getSecondLevelCacheStatistics(String regionName) {
|
||||||
|
if ( sessionFactory == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return getCacheRegionStatistics( sessionFactory.getCache().unqualifyRegionName( regionName ) );
|
return getCacheRegionStatistics( sessionFactory.getCache().unqualifyRegionName( regionName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,9 @@ public class RegionNameTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
final NaturalIdCacheStatistics naturalIdCacheStatistics = stats.getNaturalIdCacheStatistics( regionName );
|
final NaturalIdCacheStatistics naturalIdCacheStatistics = stats.getNaturalIdCacheStatistics( regionName );
|
||||||
assert naturalIdCacheStatistics != null;
|
assert naturalIdCacheStatistics != null;
|
||||||
|
|
||||||
|
final SecondLevelCacheStatistics dne = stats.getSecondLevelCacheStatistics( cachePrefix + ".does.not.exist" );
|
||||||
|
assert dne != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo (5.3) : any other API I can think of that deals with region-name?
|
// todo (5.3) : any other API I can think of that deals with region-name?
|
||||||
|
|
Loading…
Reference in New Issue