Revise @Nullable declarations in the TestContext framework

This commit is contained in:
Sam Brannen 2022-08-26 12:17:57 +02:00
parent d16fa82888
commit c32ff17821
3 changed files with 10 additions and 5 deletions

View File

@ -113,7 +113,7 @@ public class MergedContextConfiguration implements Serializable {
* @param contextLoader the resolved {@code ContextLoader}
*/
public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes,
@Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader) {
@Nullable String[] activeProfiles, ContextLoader contextLoader) {
this(testClass, locations, classes, null, activeProfiles, contextLoader);
}
@ -130,7 +130,7 @@ public class MergedContextConfiguration implements Serializable {
*/
public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes,
@Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
@Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader) {
@Nullable String[] activeProfiles, ContextLoader contextLoader) {
this(testClass, locations, classes, contextInitializerClasses, activeProfiles, contextLoader, null, null);
}
@ -151,7 +151,7 @@ public class MergedContextConfiguration implements Serializable {
*/
public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes,
@Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
@Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader,
@Nullable String[] activeProfiles, ContextLoader contextLoader,
@Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
@Nullable MergedContextConfiguration parent) {
@ -197,7 +197,7 @@ public class MergedContextConfiguration implements Serializable {
public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes,
@Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
@Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations,
@Nullable String[] propertySourceProperties, @Nullable ContextLoader contextLoader,
@Nullable String[] propertySourceProperties, ContextLoader contextLoader,
@Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
@Nullable MergedContextConfiguration parent) {
@ -235,7 +235,7 @@ public class MergedContextConfiguration implements Serializable {
@Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
@Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations,
@Nullable String[] propertySourceProperties, @Nullable Set<ContextCustomizer> contextCustomizers,
@Nullable ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
@Nullable MergedContextConfiguration parent) {
this.testClass = testClass;

View File

@ -56,6 +56,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
*/
static final ContextCache defaultContextCache = new DefaultContextCache();
@Nullable
private final AotTestMappings aotTestMappings = getAotTestMappings();
private final ContextCache contextCache;
@ -193,6 +194,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
return (this.aotTestMappings != null && this.aotTestMappings.isSupportedTestClass(testClass));
}
@Nullable
private static AotTestMappings getAotTestMappings() {
if (AotDetector.useGeneratedArtifacts()) {
try {

View File

@ -26,6 +26,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.Conventions;
import org.springframework.lang.Nullable;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.aot.AotTestMappings;
@ -59,6 +60,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
private static final Log logger = LogFactory.getLog(DependencyInjectionTestExecutionListener.class);
@Nullable
private final AotTestMappings aotTestMappings = getAotTestMappings();
@ -163,6 +165,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
return (this.aotTestMappings != null && this.aotTestMappings.isSupportedTestClass(testClass));
}
@Nullable
private static AotTestMappings getAotTestMappings() {
if (AotDetector.useGeneratedArtifacts()) {
try {