Add missing @Nullable annotations on parameters
Issue: SPR-15540
This commit is contained in:
@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
@@ -138,7 +139,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeContext(MergedContextConfiguration mergedContextConfiguration, HierarchyMode hierarchyMode) {
|
||||
public void closeContext(MergedContextConfiguration mergedContextConfiguration, @Nullable HierarchyMode hierarchyMode) {
|
||||
synchronized (this.contextCache) {
|
||||
this.contextCache.remove(mergedContextConfiguration, hierarchyMode);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -156,7 +157,7 @@ public class DefaultContextCache implements ContextCache {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void remove(MergedContextConfiguration key, HierarchyMode hierarchyMode) {
|
||||
public void remove(MergedContextConfiguration key, @Nullable HierarchyMode hierarchyMode) {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
// startKey is the level at which to begin clearing the cache, depending
|
||||
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
|
||||
* @see #processLocations(Class, String...)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
public void processContextConfiguration(@Nullable ContextConfigurationAttributes configAttributes) {
|
||||
String[] processedLocations =
|
||||
processLocations(configAttributes.getDeclaringClass(), configAttributes.getLocations());
|
||||
configAttributes.setLocations(processedLocations);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
@@ -268,7 +269,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
@Override
|
||||
public final String[] processLocations(Class<?> clazz, String... locations) {
|
||||
public final String[] processLocations(Class<?> clazz, @Nullable String... locations) {
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
|
||||
+ "Call processContextConfiguration(ContextConfigurationAttributes) instead.");
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -78,7 +79,7 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
|
||||
* @see #detectDefaultConfigurationClasses(Class)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
public void processContextConfiguration(@Nullable ContextConfigurationAttributes configAttributes) {
|
||||
if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) {
|
||||
configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass()));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
@@ -122,7 +123,7 @@ public class DefaultTestContext implements TestContext {
|
||||
* that was supplied when this {@code TestContext} was constructed.
|
||||
* @see CacheAwareContextLoaderDelegate#closeContext
|
||||
*/
|
||||
public void markApplicationContextDirty(HierarchyMode hierarchyMode) {
|
||||
public void markApplicationContextDirty(@Nullable HierarchyMode hierarchyMode) {
|
||||
this.cacheAwareContextLoaderDelegate.closeContext(this.mergedContextConfiguration, hierarchyMode);
|
||||
}
|
||||
|
||||
@@ -142,14 +143,14 @@ public class DefaultTestContext implements TestContext {
|
||||
return this.testException;
|
||||
}
|
||||
|
||||
public void updateState(Object testInstance, Method testMethod, Throwable testException) {
|
||||
public void updateState(@Nullable Object testInstance, @Nullable Method testMethod, @Nullable Throwable testException) {
|
||||
this.testInstance = testInstance;
|
||||
this.testMethod = testMethod;
|
||||
this.testException = testException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
public void setAttribute(String name, @Nullable Object value) {
|
||||
Assert.notNull(name, "Name must not be null");
|
||||
synchronized (this.attributes) {
|
||||
if (value != null) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoaderUtils;
|
||||
@@ -79,7 +80,7 @@ public class AnnotationConfigWebContextLoader extends AbstractGenericWebContextL
|
||||
* @see #detectDefaultConfigurationClasses(Class)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
public void processContextConfiguration(@Nullable ContextConfigurationAttributes configAttributes) {
|
||||
if (!configAttributes.hasClasses() && isGenerateDefaultLocations()) {
|
||||
configAttributes.setClasses(detectDefaultConfigurationClasses(configAttributes.getDeclaringClass()));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter;
|
||||
@@ -107,7 +108,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
|
||||
|
||||
@Override
|
||||
protected ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) throws Exception {
|
||||
@Nullable Object handler, Exception ex) throws Exception {
|
||||
|
||||
ModelAndView mav = super.processHandlerException(request, response, handler, ex);
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object merge(Object parent) {
|
||||
public Object merge(@Nullable Object parent) {
|
||||
if (parent instanceof RequestBuilder) {
|
||||
if (parent instanceof MockHttpServletRequestBuilder) {
|
||||
MockHttpServletRequestBuilder copiedParent = MockMvcRequestBuilders.get("/");
|
||||
|
||||
@@ -487,7 +487,7 @@ public class MockHttpServletRequestBuilder
|
||||
* @return the result of the merge
|
||||
*/
|
||||
@Override
|
||||
public Object merge(Object parent) {
|
||||
public Object merge(@Nullable Object parent) {
|
||||
if (parent == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import javax.servlet.http.Part;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.mock.web.MockMultipartHttpServletRequest;
|
||||
@@ -109,7 +110,7 @@ public class MockMultipartHttpServletRequestBuilder extends MockHttpServletReque
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object merge(Object parent) {
|
||||
public Object merge(@Nullable Object parent) {
|
||||
if (parent == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -504,7 +505,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveStringValue(String strVal) throws BeansException {
|
||||
public String resolveStringValue(@Nullable String strVal) throws BeansException {
|
||||
return this.helper.replacePlaceholders(strVal, this.resolver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -161,7 +162,7 @@ class StubWebApplicationContext implements WebApplicationContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
|
||||
public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
|
||||
return this.beanFactory.getBean(name, requiredType);
|
||||
}
|
||||
|
||||
@@ -236,27 +237,27 @@ class StubWebApplicationContext implements WebApplicationContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(ResolvableType type) {
|
||||
public String[] getBeanNamesForType(@Nullable ResolvableType type) {
|
||||
return this.beanFactory.getBeanNamesForType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(Class<?> type) {
|
||||
public String[] getBeanNamesForType(@Nullable Class<?> type) {
|
||||
return this.beanFactory.getBeanNamesForType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
|
||||
public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
|
||||
return this.beanFactory.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException {
|
||||
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
|
||||
return this.beanFactory.getBeansOfType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
throws BeansException {
|
||||
|
||||
return this.beanFactory.getBeansOfType(type, includeNonSingletons, allowEagerInit);
|
||||
@@ -302,12 +303,12 @@ class StubWebApplicationContext implements WebApplicationContext {
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object args[], String defaultMessage, Locale locale) {
|
||||
public String getMessage(String code, @Nullable Object args[], String defaultMessage, Locale locale) {
|
||||
return this.messageSource.getMessage(code, args, defaultMessage, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object args[], Locale locale) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable Object args[], Locale locale) throws NoSuchMessageException {
|
||||
return this.messageSource.getMessage(code, args, locale);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user