Merge branch '6.1.x'
This commit is contained in:
commit
96d9081190
|
|
@ -97,6 +97,7 @@ public class MockFilterConfig implements FilterConfig {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
|
|
|
|||
|
|
@ -383,6 +383,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
|||
// ---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getAttribute(String name) {
|
||||
checkActive();
|
||||
return this.attributes.get(name);
|
||||
|
|
@ -637,6 +638,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String[] getParameterValues(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.parameters.get(name);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ public class MockHttpSession implements HttpSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getAttribute(String name) {
|
||||
assertIsValid();
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public MultipartFile getFile(String name) {
|
||||
return this.multipartFiles.getFirst(name);
|
||||
}
|
||||
|
|
@ -117,6 +118,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getMultipartContentType(String paramOrFileName) {
|
||||
MultipartFile file = getFile(paramOrFileName);
|
||||
if (file != null) {
|
||||
|
|
@ -154,6 +156,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpHeaders getMultipartHeaders(String paramOrFileName) {
|
||||
MultipartFile file = getFile(paramOrFileName);
|
||||
if (file != null) {
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ public class MockServletConfig implements ServletConfig {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ public class MockServletContext implements ServletContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServletContext getContext(String contextPath) {
|
||||
if (this.contextPath.equals(contextPath)) {
|
||||
return this;
|
||||
|
|
@ -376,6 +377,7 @@ public class MockServletContext implements ServletContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public RequestDispatcher getNamedDispatcher(String path) {
|
||||
return this.namedRequestDispatchers.get(path);
|
||||
}
|
||||
|
|
@ -465,6 +467,7 @@ public class MockServletContext implements ServletContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ public class MockSessionCookieConfig implements SessionCookieConfig {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getAttribute(String name) {
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -569,6 +569,7 @@ public final class MockServerRequest implements ServerRequest {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InetSocketAddress host() {
|
||||
return delegate().getHost();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.test.context;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy for components that process failures related to application contexts
|
||||
|
|
@ -41,6 +42,6 @@ public interface ApplicationContextFailureProcessor {
|
|||
* @param context the application context that did not load successfully
|
||||
* @param exception the exception thrown while loading the application context
|
||||
*/
|
||||
void processLoadFailure(ApplicationContext context, Throwable exception);
|
||||
void processLoadFailure(ApplicationContext context, @Nullable Throwable exception);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.test.context;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface for loading an {@link ApplicationContext} for an integration
|
||||
|
|
@ -157,7 +156,7 @@ public interface SmartContextLoader extends ContextLoader {
|
|||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
default String[] processLocations(Class<?> clazz, @Nullable String... locations) {
|
||||
default String[] processLocations(Class<?> clazz, String... locations) {
|
||||
throw new UnsupportedOperationException("""
|
||||
SmartContextLoader does not support the ContextLoader SPI. \
|
||||
Call processContextConfiguration(ContextConfigurationAttributes) instead.""");
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.springframework.aot.hint.RuntimeHints;
|
|||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeHint;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +40,7 @@ import org.springframework.util.ClassUtils;
|
|||
class TestContextRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints runtimeHints, ClassLoader classLoader) {
|
||||
public void registerHints(RuntimeHints runtimeHints, @Nullable ClassLoader classLoader) {
|
||||
boolean servletPresent = ClassUtils.isPresent("jakarta.servlet.Servlet", classLoader);
|
||||
boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure", classLoader);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.function.SupplierUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +39,7 @@ class DynamicValuesPropertySource extends MapPropertySource {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getProperty(String name) {
|
||||
return SupplierUtils.resolve(super.getProperty(name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -459,6 +459,7 @@ public abstract class TestPropertySourceUtils {
|
|||
private final LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object put(Object key, Object value) {
|
||||
if (key instanceof String str) {
|
||||
return this.map.put(str, value);
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
|||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private Throwable getTestResultException(ITestResult testResult) {
|
||||
Throwable testResultException = testResult.getThrowable();
|
||||
if (testResultException instanceof InvocationTargetException) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
|||
protected final TransactionAttributeSource attributeSource = new AnnotationTransactionAttributeSource(false) {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttribute findTransactionAttribute(Class<?> clazz) {
|
||||
// @Transactional present in inheritance hierarchy?
|
||||
TransactionAttribute result = super.findTransactionAttribute(clazz);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.http.client.MockClientHttpRequest;
|
||||
import org.springframework.test.web.client.ResponseCreator;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -59,7 +60,7 @@ public class ExecutingResponseCreator implements ResponseCreator {
|
|||
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException {
|
||||
public ClientHttpResponse createResponse(@Nullable ClientHttpRequest request) throws IOException {
|
||||
Assert.state(request instanceof MockClientHttpRequest, "Expected a MockClientHttpRequest");
|
||||
MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
|
||||
ClientHttpRequest newRequest = this.requestFactory.createRequest(mockRequest.getURI(), mockRequest.getMethod());
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class DefaultMvcResult implements MvcResult {
|
|||
return RequestContextUtils.getOutputFlashMap(this.mockRequest);
|
||||
}
|
||||
|
||||
public void setAsyncResult(Object asyncResult) {
|
||||
public void setAsyncResult(@Nullable Object asyncResult) {
|
||||
this.asyncResult.set(asyncResult);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
|
|||
WebAsyncUtils.getAsyncManager(request).registerCallableInterceptor(KEY,
|
||||
new CallableProcessingInterceptor() {
|
||||
@Override
|
||||
public <T> void postProcess(NativeWebRequest r, Callable<T> task, Object value) {
|
||||
public <T> void postProcess(NativeWebRequest r, Callable<T> task, @Nullable Object value) {
|
||||
// We got the result, must also wait for the dispatch
|
||||
getMvcResult(request).setAsyncResult(value);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
|
|||
WebAsyncUtils.getAsyncManager(request).registerDeferredResultInterceptor(KEY,
|
||||
new DeferredResultProcessingInterceptor() {
|
||||
@Override
|
||||
public <T> void postProcess(NativeWebRequest r, DeferredResult<T> result, Object value) {
|
||||
public <T> void postProcess(NativeWebRequest r, DeferredResult<T> result, @Nullable Object value) {
|
||||
getMvcResult(request).setAsyncResult(value);
|
||||
}
|
||||
});
|
||||
|
|
@ -118,6 +118,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
|
||||
HandlerExecutionChain chain = super.getHandler(request);
|
||||
if (chain != null) {
|
||||
|
|
@ -138,6 +139,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response,
|
||||
@Nullable Object handler, Exception ex) throws Exception {
|
||||
|
||||
|
|
|
|||
|
|
@ -451,6 +451,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public HttpSession getSession(boolean create) {
|
||||
HttpSession session = super.getSession(false);
|
||||
if (session == null && create) {
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ class StubWebApplicationContext implements WebApplicationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ApplicationContext getParent() {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -218,11 +219,13 @@ class StubWebApplicationContext implements WebApplicationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
|
||||
return this.beanFactory.getType(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException {
|
||||
return this.beanFactory.getType(name, allowFactoryBeanInit);
|
||||
}
|
||||
|
|
@ -337,6 +340,7 @@ class StubWebApplicationContext implements WebApplicationContext {
|
|||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BeanFactory getParentBeanFactory() {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -352,6 +356,7 @@ class StubWebApplicationContext implements WebApplicationContext {
|
|||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) {
|
||||
return this.messageSource.getMessage(code, args, defaultMessage, locale);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ApplicationContextFailureProcessor;
|
||||
|
||||
/**
|
||||
|
|
@ -37,10 +38,10 @@ public class TrackingApplicationContextFailureProcessor implements ApplicationCo
|
|||
|
||||
|
||||
@Override
|
||||
public void processLoadFailure(ApplicationContext context, Throwable exception) {
|
||||
public void processLoadFailure(ApplicationContext context, @Nullable Throwable exception) {
|
||||
loadFailures.add(new LoadFailure(context, exception));
|
||||
}
|
||||
|
||||
public record LoadFailure(ApplicationContext context, Throwable exception) {}
|
||||
public record LoadFailure(ApplicationContext context, @Nullable Throwable exception) {}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue