File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
main/java/org/hibernate/stat/internal
test/java/org/hibernate/test/cache Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -625,10 +625,12 @@ public CacheRegionStatisticsImpl getCacheRegionStatistics(String regionName) {
625
625
return l2CacheStatsMap .computeIfAbsent (
626
626
regionName ,
627
627
s -> {
628
- final Region region = sessionFactory .getCache ().getRegion ( regionName );
628
+ Region region = sessionFactory .getCache ().getRegion ( regionName );
629
629
630
630
if ( region == null ) {
631
- throw new IllegalArgumentException ( "Unknown cache region : " + regionName );
631
+ // this is the pre-5.3 behavior. and since this is a pre-5.3 method it should behave consistently
632
+ // NOTE that this method is deprecated
633
+ region = sessionFactory .getCache ().getQueryResultsCache ( regionName ).getRegion ();
632
634
}
633
635
634
636
return new CacheRegionStatisticsImpl ( region );
@@ -638,6 +640,9 @@ public CacheRegionStatisticsImpl getCacheRegionStatistics(String regionName) {
638
640
639
641
@ Override
640
642
public CacheRegionStatisticsImpl getSecondLevelCacheStatistics (String regionName ) {
643
+ if ( sessionFactory == null ) {
644
+ return null ;
645
+ }
641
646
return getCacheRegionStatistics ( sessionFactory .getCache ().unqualifyRegionName ( regionName ) );
642
647
}
643
648
Original file line number Diff line number Diff line change @@ -82,6 +82,9 @@ public void testLegacyStatsApi() {
82
82
83
83
final NaturalIdCacheStatistics naturalIdCacheStatistics = stats .getNaturalIdCacheStatistics ( regionName );
84
84
assert naturalIdCacheStatistics != null ;
85
+
86
+ final SecondLevelCacheStatistics dne = stats .getSecondLevelCacheStatistics ( cachePrefix + ".does.not.exist" );
87
+ assert dne != null ;
85
88
}
86
89
87
90
// todo (5.3) : any other API I can think of that deals with region-name?
You can’t perform that action at this time.
0 commit comments