From c32ff17821f1b24298b94a4792ec571890cf4971 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 26 Aug 2022 12:17:57 +0200 Subject: [PATCH] Revise @Nullable declarations in the TestContext framework --- .../test/context/MergedContextConfiguration.java | 10 +++++----- .../cache/DefaultCacheAwareContextLoaderDelegate.java | 2 ++ .../DependencyInjectionTestExecutionListener.java | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java index 97841c8c80..57a15e7561 100644 --- a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java @@ -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>> 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>> 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>> 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>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations, @Nullable String[] propertySourceProperties, @Nullable Set contextCustomizers, - @Nullable ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, + ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) { this.testClass = testClass; 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 2bf58b244c..24ea45a1f9 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 @@ -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 { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java index e440c4c399..ce3780db7f 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java @@ -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 {