Consistent use of @Nullable in spring-test
This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract. Issue: SPR-15540
This commit is contained in:
@@ -1352,7 +1352,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAll(String key, List<String> values) {
|
||||
public void addAll(String key, List<? extends String> values) {
|
||||
List<String> currentValues = this.headers.computeIfAbsent(key, k -> new LinkedList<>());
|
||||
currentValues.addAll(values);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.MultiValueMap;
|
||||
public interface ClientHttpResponse extends ReactiveHttpInputMessage {
|
||||
|
||||
/**
|
||||
* @return the HTTP status as an {@link HttpStatus} enum value
|
||||
* Return the HTTP status as an {@link HttpStatus} enum value.
|
||||
*/
|
||||
HttpStatus getStatusCode();
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -142,17 +141,12 @@ public class Jackson2JsonEncoder extends Jackson2CodecSupport implements HttpMes
|
||||
private DataBuffer encodeValue(Object value, @Nullable MimeType mimeType, DataBufferFactory bufferFactory,
|
||||
ResolvableType elementType, @Nullable Map<String, Object> hints) {
|
||||
|
||||
TypeFactory typeFactory = this.objectMapper.getTypeFactory();
|
||||
JavaType javaType = typeFactory.constructType(elementType.getType());
|
||||
if (elementType.isInstance(value)) {
|
||||
javaType = getJavaType(elementType.getType(), null);
|
||||
}
|
||||
|
||||
JavaType javaType = getJavaType(elementType.getType(), null);
|
||||
Class<?> jsonView = (hints != null ? (Class<?>) hints.get(Jackson2CodecSupport.JSON_VIEW_HINT) : null);
|
||||
ObjectWriter writer = (jsonView != null ?
|
||||
this.objectMapper.writerWithView(jsonView) : this.objectMapper.writer());
|
||||
|
||||
if (javaType != null && javaType.isContainerType()) {
|
||||
if (javaType.isContainerType()) {
|
||||
writer = writer.forType(javaType);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class RequestContextHolder {
|
||||
* @param attributes the RequestAttributes to expose
|
||||
* @see #setRequestAttributes(RequestAttributes, boolean)
|
||||
*/
|
||||
public static void setRequestAttributes(RequestAttributes attributes) {
|
||||
public static void setRequestAttributes(@Nullable RequestAttributes attributes) {
|
||||
setRequestAttributes(attributes, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user