Add more @Nullable parameters based on null usage
Issue: SPR-15540
This commit is contained in:
@@ -1030,7 +1030,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
*/
|
||||
@Nullable
|
||||
protected ServletRequestAttributes buildRequestAttributes(
|
||||
HttpServletRequest request, HttpServletResponse response, RequestAttributes previousAttributes) {
|
||||
HttpServletRequest request, HttpServletResponse response, @Nullable RequestAttributes previousAttributes) {
|
||||
|
||||
if (previousAttributes == null || previousAttributes instanceof ServletRequestAttributes) {
|
||||
return new ServletRequestAttributes(request, response);
|
||||
@@ -1055,7 +1055,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
}
|
||||
|
||||
private void resetContextHolders(HttpServletRequest request,
|
||||
LocaleContext prevLocaleContext, RequestAttributes previousAttributes) {
|
||||
@Nullable LocaleContext prevLocaleContext, @Nullable RequestAttributes previousAttributes) {
|
||||
|
||||
LocaleContextHolder.setLocaleContext(prevLocaleContext, this.threadContextInheritable);
|
||||
RequestContextHolder.setRequestAttributes(previousAttributes, this.threadContextInheritable);
|
||||
|
||||
@@ -162,7 +162,7 @@ public class HandlerExecutionChain {
|
||||
* Will just invoke afterCompletion for all interceptors whose preHandle invocation
|
||||
* has successfully completed and returned true.
|
||||
*/
|
||||
void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, Exception ex)
|
||||
void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, @Nullable Exception ex)
|
||||
throws Exception {
|
||||
|
||||
HandlerInterceptor[] interceptors = getInterceptors();
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract class MvcNamespaceUtils {
|
||||
* under that well-known name, unless already registered.
|
||||
* @return a RuntimeBeanReference to this {@link UrlPathHelper} instance
|
||||
*/
|
||||
public static RuntimeBeanReference registerUrlPathHelper(RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) {
|
||||
public static RuntimeBeanReference registerUrlPathHelper(@Nullable RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) {
|
||||
if (urlPathHelperRef != null) {
|
||||
if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
|
||||
parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME);
|
||||
@@ -92,7 +92,7 @@ abstract class MvcNamespaceUtils {
|
||||
* under that well-known name, unless already registered.
|
||||
* @return a RuntimeBeanReference to this {@link PathMatcher} instance
|
||||
*/
|
||||
public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
|
||||
public static RuntimeBeanReference registerPathMatcher(@Nullable RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
|
||||
if (pathMatcherRef != null) {
|
||||
if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
|
||||
parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
|
||||
@@ -161,7 +161,7 @@ abstract class MvcNamespaceUtils {
|
||||
* if a non-null CORS configuration is provided.
|
||||
* @return a RuntimeBeanReference to this {@code Map<String, CorsConfiguration>} instance
|
||||
*/
|
||||
public static RuntimeBeanReference registerCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations, ParserContext parserContext, Object source) {
|
||||
public static RuntimeBeanReference registerCorsConfigurations(@Nullable Map<String, CorsConfiguration> corsConfigurations, ParserContext parserContext, Object source) {
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(CORS_CONFIGURATION_BEAN_NAME)) {
|
||||
RootBeanDefinition corsConfigurationsDef = new RootBeanDefinition(LinkedHashMap.class);
|
||||
corsConfigurationsDef.setSource(source);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DefaultServletHandlerConfigurer {
|
||||
* This is useful when the default Servlet cannot be auto-detected, for example when it has been manually configured.
|
||||
* @see DefaultServletHttpRequestHandler
|
||||
*/
|
||||
public void enable(String defaultServletName) {
|
||||
public void enable(@Nullable String defaultServletName) {
|
||||
handler = new DefaultServletHttpRequestHandler();
|
||||
handler.setDefaultServletName(defaultServletName);
|
||||
handler.setServletContext(servletContext);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
@@ -301,7 +302,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||
* @since 4.2
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass, Type declaredType) {
|
||||
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass, @Nullable Type declaredType) {
|
||||
Set<MediaType> mediaTypes = (Set<MediaType>) request.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
||||
if (!CollectionUtils.isEmpty(mediaTypes)) {
|
||||
return new ArrayList<>(mediaTypes);
|
||||
|
||||
@@ -159,7 +159,7 @@ public class MvcUriComponentsBuilder {
|
||||
* @param controllerType the controller to build a URI for
|
||||
* @return a UriComponentsBuilder instance (never {@code null})
|
||||
*/
|
||||
public static UriComponentsBuilder fromController(UriComponentsBuilder builder,
|
||||
public static UriComponentsBuilder fromController(@Nullable UriComponentsBuilder builder,
|
||||
Class<?> controllerType) {
|
||||
|
||||
builder = getBaseUrlToUse(builder);
|
||||
@@ -328,7 +328,7 @@ public class MvcUriComponentsBuilder {
|
||||
* if there is no unique match
|
||||
* @since 4.2
|
||||
*/
|
||||
public static MethodArgumentBuilder fromMappingName(UriComponentsBuilder builder, String name) {
|
||||
public static MethodArgumentBuilder fromMappingName(@Nullable UriComponentsBuilder builder, String name) {
|
||||
RequestMappingInfoHandlerMapping handlerMapping = getRequestMappingInfoHandlerMapping();
|
||||
List<HandlerMethod> handlerMethods = handlerMapping.getHandlerMethodsForMappingName(name);
|
||||
if (handlerMethods == null) {
|
||||
@@ -383,7 +383,7 @@ public class MvcUriComponentsBuilder {
|
||||
(controllerType != null ? controllerType : method.getDeclaringClass()), method, args);
|
||||
}
|
||||
|
||||
private static UriComponentsBuilder fromMethodInternal(UriComponentsBuilder baseUrl,
|
||||
private static UriComponentsBuilder fromMethodInternal(@Nullable UriComponentsBuilder baseUrl,
|
||||
Class<?> controllerType, Method method, Object... args) {
|
||||
|
||||
baseUrl = getBaseUrlToUse(baseUrl);
|
||||
@@ -692,7 +692,7 @@ public class MvcUriComponentsBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) {
|
||||
public Object intercept(Object obj, Method method, Object[] args, @Nullable MethodProxy proxy) {
|
||||
if (getControllerMethod.equals(method)) {
|
||||
return this.controllerMethod;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class ResponseBodyEmitter {
|
||||
* @throws IOException raised when an I/O error occurs
|
||||
* @throws java.lang.IllegalStateException wraps any other errors
|
||||
*/
|
||||
public synchronized void send(Object object, MediaType mediaType) throws IOException {
|
||||
public synchronized void send(Object object, @Nullable MediaType mediaType) throws IOException {
|
||||
Assert.state(!this.complete, "ResponseBodyEmitter is already set complete");
|
||||
sendInternal(object, mediaType);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
* @param status the response status
|
||||
* @param request the current request
|
||||
*/
|
||||
protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body,
|
||||
protected ResponseEntity<Object> handleExceptionInternal(Exception ex, @Nullable Object body,
|
||||
HttpHeaders headers, HttpStatus status, WebRequest request) {
|
||||
|
||||
if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -103,7 +104,7 @@ public class SseEmitter extends ResponseBodyEmitter {
|
||||
* @throws IOException raised when an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
public void send(Object object, MediaType mediaType) throws IOException {
|
||||
public void send(Object object, @Nullable MediaType mediaType) throws IOException {
|
||||
if (object != null) {
|
||||
send(event().data(object, mediaType));
|
||||
}
|
||||
@@ -173,7 +174,7 @@ public class SseEmitter extends ResponseBodyEmitter {
|
||||
/**
|
||||
* Add an SSE "data" line.
|
||||
*/
|
||||
SseEventBuilder data(Object object, MediaType mediaType);
|
||||
SseEventBuilder data(Object object, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Return one or more Object-MediaType pairs to write via
|
||||
@@ -223,7 +224,7 @@ public class SseEmitter extends ResponseBodyEmitter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SseEventBuilder data(Object object, MediaType mediaType) {
|
||||
public SseEventBuilder data(Object object, @Nullable MediaType mediaType) {
|
||||
append("data:");
|
||||
saveAppendedText();
|
||||
this.dataToSend.add(new DataWithMediaType(object, mediaType));
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -212,7 +213,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
|
||||
private final Resource resource;
|
||||
|
||||
|
||||
public LineOutput(String line, Resource resource) {
|
||||
public LineOutput(String line, @Nullable Resource resource) {
|
||||
this.line = line;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
|
||||
|
||||
|
||||
@Override
|
||||
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
|
||||
public Resource resolveResource(@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
|
||||
ResourceResolver resolver = getNext();
|
||||
if (resolver == null) {
|
||||
return null;
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface ResourceResolverChain {
|
||||
* @return the resolved resource or {@code null} if unresolved
|
||||
*/
|
||||
@Nullable
|
||||
Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations);
|
||||
Resource resolveResource(@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations);
|
||||
|
||||
/**
|
||||
* Resolve the externally facing <em>public</em> URL path for clients to use
|
||||
|
||||
@@ -222,7 +222,7 @@ public class RequestContext {
|
||||
* @see org.springframework.web.servlet.DispatcherServlet#LOCALE_RESOLVER_ATTRIBUTE
|
||||
* @see org.springframework.web.servlet.DispatcherServlet#THEME_RESOLVER_ATTRIBUTE
|
||||
*/
|
||||
protected void initContext(HttpServletRequest request, HttpServletResponse response, @Nullable ServletContext servletContext,
|
||||
protected void initContext(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable ServletContext servletContext,
|
||||
@Nullable Map<String, Object> model) {
|
||||
|
||||
this.request = request;
|
||||
|
||||
@@ -105,7 +105,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
||||
* <p>May be ignored by subclasses if the view itself is assumed
|
||||
* to set the content type, e.g. in case of JSPs.
|
||||
*/
|
||||
public void setContentType(String contentType) {
|
||||
public void setContentType(@Nullable String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
|
||||
* @since 4.2.1
|
||||
*/
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
public void setContentType(@Nullable String contentType) {
|
||||
super.setContentType(contentType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user