Browse Source

Ensure context cache stats are logged when ApplicationContext fails to load

Closes gh-30635
pull/30651/head
Sam Brannen 3 years ago
parent
commit
1a26e17f41
  1. 5
      spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java

5
spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java vendored

@ -109,6 +109,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext @@ -109,6 +109,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
mergedContextConfiguration = replaceIfNecessary(mergedContextConfiguration);
synchronized (this.contextCache) {
ApplicationContext context = this.contextCache.get(mergedContextConfiguration);
try {
if (context == null) {
try {
if (mergedContextConfiguration instanceof AotMergedContextConfiguration aotMergedConfig) {
@ -149,8 +150,10 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext @@ -149,8 +150,10 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
System.identityHashCode(context), mergedContextConfiguration));
}
}
}
finally {
this.contextCache.logStatistics();
}
return context;
}

Loading…
Cancel
Save