Add more @Nullable parameters based on null usage

Issue: SPR-15540
This commit is contained in:
Sebastien Deleuze
2017-05-31 21:35:52 +02:00
parent f9b319d3ba
commit 1f28825f9d
219 changed files with 441 additions and 355 deletions

View File

@@ -74,7 +74,7 @@ public class BindingContext {
* @param name the name of the target object
* @return the created data binder
*/
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, Object target, String name) {
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, @Nullable Object target, String name) {
WebExchangeDataBinder dataBinder = new WebExchangeDataBinder(target, name);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder);

View File

@@ -35,6 +35,7 @@ import reactor.core.publisher.Mono;
import reactor.core.publisher.SynchronousSink;
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;
@@ -242,7 +243,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;
}

View File

@@ -48,7 +48,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
@Override
public Mono<Resource> resolveResource(ServerWebExchange exchange, String requestPath,
public Mono<Resource> resolveResource(@Nullable ServerWebExchange exchange, String requestPath,
List<? extends Resource> locations) {
ResourceResolver resolver = getNext();

View File

@@ -21,6 +21,7 @@ import java.util.List;
import reactor.core.publisher.Mono;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.web.server.ServerWebExchange;
/**
@@ -40,7 +41,7 @@ public interface ResourceResolverChain {
* @param locations the locations to search in when looking up resources
* @return the resolved resource or an empty {@code Mono} if unresolved
*/
Mono<Resource> resolveResource(ServerWebExchange exchange, String requestPath,
Mono<Resource> resolveResource(@Nullable ServerWebExchange exchange, String requestPath,
List<? extends Resource> locations);
/**

View File

@@ -38,6 +38,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.InitBinder;
@@ -336,7 +337,7 @@ class ControllerMethodResolver {
private ArgumentResolverRegistrar(ArgumentResolverConfigurer resolvers,
ServerCodecConfigurer codecs, boolean modelAttribute) {
@Nullable ServerCodecConfigurer codecs, boolean modelAttribute) {
this.customResolvers = resolvers.getCustomResolvers();
this.messageReaders = codecs != null ? codecs.getReaders() : null;

View File

@@ -26,6 +26,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.RequestEntity;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.web.reactive.BindingContext;
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
import org.springframework.web.server.ServerWebExchange;
@@ -63,7 +64,7 @@ public class HttpEntityArgumentResolver extends AbstractMessageReaderArgumentRes
.defaultIfEmpty(createEntity(null, entityType, exchange.getRequest()));
}
private Object createEntity(Object body, Class<?> entityType, ServerHttpRequest request) {
private Object createEntity(@Nullable Object body, Class<?> entityType, ServerHttpRequest request) {
return RequestEntity.class.equals(entityType) ?
new RequestEntity<>(body, request.getHeaders(), request.getMethod(), request.getURI()) :
new HttpEntity<>(body, request.getHeaders());