diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java index 8f537a9e55..d773c7fb45 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java @@ -66,7 +66,8 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext */ static final ContextCache defaultContextCache = new DefaultContextCache(); - private List contextFailureProcessors = TestContextSpringFactoriesUtils + + private final List contextFailureProcessors = TestContextSpringFactoriesUtils .loadFactoryImplementations(ApplicationContextFailureProcessor.class); private final AotTestContextInitializers aotTestContextInitializers = new AotTestContextInitializers(); @@ -99,8 +100,9 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext @Override public boolean isContextLoaded(MergedContextConfiguration mergedContextConfiguration) { + mergedContextConfiguration = replaceIfNecessary(mergedContextConfiguration); synchronized (this.contextCache) { - return this.contextCache.contains(replaceIfNecessary(mergedContextConfiguration)); + return this.contextCache.contains(mergedContextConfiguration); } } @@ -158,8 +160,9 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext @Override public void closeContext(MergedContextConfiguration mergedContextConfiguration, @Nullable HierarchyMode hierarchyMode) { + mergedContextConfiguration = replaceIfNecessary(mergedContextConfiguration); synchronized (this.contextCache) { - this.contextCache.remove(replaceIfNecessary(mergedContextConfiguration), hierarchyMode); + this.contextCache.remove(mergedContextConfiguration, hierarchyMode); } } diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index bfb1b70452..f830701285 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,7 +158,7 @@ public class DefaultContextCache implements ContextCache { Assert.notNull(key, "Key must not be null"); // startKey is the level at which to begin clearing the cache, - // depending on the configured hierarchy mode.s + // depending on the configured hierarchy mode. MergedContextConfiguration startKey = key; if (hierarchyMode == HierarchyMode.EXHAUSTIVE) { MergedContextConfiguration parent = startKey.getParent();