Switch to JSpecify annotations
This commit updates the whole Spring Framework codebase to use JSpecify annotations instead of Spring null-safety annotations with JSR 305 semantics. JSpecify provides signficant enhancements such as properly defined specifications, a canonical dependency with no split-package issue, better tooling, better Kotlin integration and the capability to specify generic type, array and varargs element null-safety. Generic type null-safety is not defined by this commit yet and will be specified later. A key difference is that Spring null-safety annotations, following JSR 305 semantics, apply to fields, parameters and return values, while JSpecify annotations apply to type usages. That's why this commit moves nullability annotations closer to the type for fields and return values. See gh-28797
This commit is contained in:
@@ -33,9 +33,9 @@ import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpMessage;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -58,8 +58,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFirst(String key) {
|
||||
public @Nullable String getFirst(String key) {
|
||||
Header header = this.message.getFirstHeader(key);
|
||||
return (header != null ? header.getValue() : null);
|
||||
}
|
||||
@@ -117,9 +116,8 @@ class HeadersAdaptersBaseline {
|
||||
Arrays.stream(this.message.getHeaders()).anyMatch(h -> h.getValue().equals(value)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
List<String> values = null;
|
||||
if (containsKey(key)) {
|
||||
Header[] headers = this.message.getHeaders((String) key);
|
||||
@@ -131,17 +129,15 @@ class HeadersAdaptersBaseline {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, List<String> values) {
|
||||
public @Nullable List<String> put(String key, List<String> values) {
|
||||
List<String> oldValues = remove(key);
|
||||
values.forEach(value -> add(key, value));
|
||||
return oldValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
public @Nullable List<String> remove(Object key) {
|
||||
if (key instanceof String headerName) {
|
||||
List<String> oldValues = get(key);
|
||||
this.message.removeHeaders(headerName);
|
||||
@@ -249,8 +245,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
private final HttpFields headers;
|
||||
|
||||
@Nullable
|
||||
private final HttpFields.Mutable mutable;
|
||||
private final HttpFields.@Nullable Mutable mutable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -343,9 +338,8 @@ class HeadersAdaptersBaseline {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
List<String> list = null;
|
||||
if (key instanceof String name) {
|
||||
for (HttpField f : this.headers) {
|
||||
@@ -360,9 +354,8 @@ class HeadersAdaptersBaseline {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, List<String> value) {
|
||||
public @Nullable List<String> put(String key, List<String> value) {
|
||||
HttpFields.Mutable mutableHttpFields = mutableFields();
|
||||
List<String> oldValues = get(key);
|
||||
|
||||
@@ -383,9 +376,8 @@ class HeadersAdaptersBaseline {
|
||||
return oldValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
public @Nullable List<String> remove(Object key) {
|
||||
HttpFields.Mutable mutableHttpFields = mutableFields();
|
||||
List<String> list = null;
|
||||
if (key instanceof String name) {
|
||||
@@ -515,8 +507,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
private final Iterator<String> iterator;
|
||||
|
||||
@Nullable
|
||||
private String currentName;
|
||||
private @Nullable String currentName;
|
||||
|
||||
private HeaderNamesIterator(Iterator<String> iterator) {
|
||||
this.iterator = iterator;
|
||||
@@ -563,8 +554,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFirst(String key) {
|
||||
public @Nullable String getFirst(String key) {
|
||||
return this.headers.get(key);
|
||||
}
|
||||
|
||||
@@ -632,25 +622,22 @@ class HeadersAdaptersBaseline {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
if (containsKey(key)) {
|
||||
return this.headers.getAll((String) key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, @Nullable List<String> value) {
|
||||
public @Nullable List<String> put(String key, @Nullable List<String> value) {
|
||||
List<String> previousValues = this.headers.getAll(key);
|
||||
this.headers.set(key, value);
|
||||
return previousValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
public @Nullable List<String> remove(Object key) {
|
||||
if (key instanceof String headerName) {
|
||||
List<String> previousValues = this.headers.getAll(headerName);
|
||||
this.headers.remove(headerName);
|
||||
@@ -762,8 +749,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
private final Iterator<String> iterator;
|
||||
|
||||
@Nullable
|
||||
private String currentName;
|
||||
private @Nullable String currentName;
|
||||
|
||||
private HeaderNamesIterator(Iterator<String> iterator) {
|
||||
this.iterator = iterator;
|
||||
@@ -810,8 +796,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFirst(String key) {
|
||||
public @Nullable String getFirst(String key) {
|
||||
CharSequence value = this.headers.get(key);
|
||||
return (value != null ? value.toString() : null);
|
||||
}
|
||||
@@ -876,8 +861,7 @@ class HeadersAdaptersBaseline {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
Iterator<CharSequence> iterator = this.headers.valuesIterator((CharSequence) key);
|
||||
if (iterator.hasNext()) {
|
||||
List<String> result = new ArrayList<>();
|
||||
@@ -887,17 +871,15 @@ class HeadersAdaptersBaseline {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> put(String key, @Nullable List<String> value) {
|
||||
public @Nullable List<String> put(String key, @Nullable List<String> value) {
|
||||
List<String> previousValues = get(key);
|
||||
this.headers.set(key, value);
|
||||
return previousValues;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> remove(Object key) {
|
||||
public @Nullable List<String> remove(Object key) {
|
||||
if (key instanceof String headerName) {
|
||||
List<String> previousValues = get(headerName);
|
||||
this.headers.remove(headerName);
|
||||
@@ -1010,8 +992,7 @@ class HeadersAdaptersBaseline {
|
||||
|
||||
private final Iterator<CharSequence> iterator;
|
||||
|
||||
@Nullable
|
||||
private CharSequence currentName;
|
||||
private @Nullable CharSequence currentName;
|
||||
|
||||
private HeaderNamesIterator(Iterator<CharSequence> iterator) {
|
||||
this.iterator = iterator;
|
||||
|
||||
@@ -19,7 +19,8 @@ package org.springframework.http;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -51,8 +52,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class CacheControl {
|
||||
|
||||
@Nullable
|
||||
private Duration maxAge;
|
||||
private @Nullable Duration maxAge;
|
||||
|
||||
private boolean noCache = false;
|
||||
|
||||
@@ -68,14 +68,11 @@ public class CacheControl {
|
||||
|
||||
private boolean proxyRevalidate = false;
|
||||
|
||||
@Nullable
|
||||
private Duration staleWhileRevalidate;
|
||||
private @Nullable Duration staleWhileRevalidate;
|
||||
|
||||
@Nullable
|
||||
private Duration staleIfError;
|
||||
private @Nullable Duration staleIfError;
|
||||
|
||||
@Nullable
|
||||
private Duration sMaxAge;
|
||||
private @Nullable Duration sMaxAge;
|
||||
|
||||
private boolean immutable = false;
|
||||
|
||||
@@ -341,8 +338,7 @@ public class CacheControl {
|
||||
* Return the "Cache-Control" header value, if any.
|
||||
* @return the header value, or {@code null} if no directive was added
|
||||
*/
|
||||
@Nullable
|
||||
public String getHeaderValue() {
|
||||
public @Nullable String getHeaderValue() {
|
||||
String headerValue = toHeaderValue();
|
||||
return (StringUtils.hasText(headerValue) ? headerValue : null);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
@@ -70,17 +71,13 @@ public final class ContentDisposition {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private final String type;
|
||||
private final @Nullable String type;
|
||||
|
||||
@Nullable
|
||||
private final String name;
|
||||
private final @Nullable String name;
|
||||
|
||||
@Nullable
|
||||
private final String filename;
|
||||
private final @Nullable String filename;
|
||||
|
||||
@Nullable
|
||||
private final Charset charset;
|
||||
private final @Nullable Charset charset;
|
||||
|
||||
|
||||
/**
|
||||
@@ -126,16 +123,14 @@ public final class ContentDisposition {
|
||||
* @see #isFormData()
|
||||
* @see #isInline()
|
||||
*/
|
||||
@Nullable
|
||||
public String getType() {
|
||||
public @Nullable String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the {@literal name} parameter, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
public @Nullable String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -144,16 +139,14 @@ public final class ContentDisposition {
|
||||
* from BASE64 encoding based on RFC 2047, or of the {@literal filename*}
|
||||
* parameter, possibly decoded as defined in the RFC 5987.
|
||||
*/
|
||||
@Nullable
|
||||
public String getFilename() {
|
||||
public @Nullable String getFilename() {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the charset defined in {@literal filename*} parameter, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public Charset getCharset() {
|
||||
public @Nullable Charset getCharset() {
|
||||
return this.charset;
|
||||
}
|
||||
|
||||
@@ -603,14 +596,11 @@ public final class ContentDisposition {
|
||||
|
||||
private final String type;
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
private @Nullable String name;
|
||||
|
||||
@Nullable
|
||||
private String filename;
|
||||
private @Nullable String filename;
|
||||
|
||||
@Nullable
|
||||
private Charset charset;
|
||||
private @Nullable Charset charset;
|
||||
|
||||
|
||||
public BuilderImpl(String type) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.http;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link HttpStatusCode}.
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -65,8 +66,7 @@ public class HttpEntity<T> {
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
@Nullable
|
||||
private final T body;
|
||||
private final @Nullable T body;
|
||||
|
||||
|
||||
/**
|
||||
@@ -113,8 +113,7 @@ public class HttpEntity<T> {
|
||||
/**
|
||||
* Returns the body of this entity.
|
||||
*/
|
||||
@Nullable
|
||||
public T getBody() {
|
||||
public @Nullable T getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ import java.util.StringJoiner;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
@@ -659,8 +660,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Access-Control-Allow-Origin} response header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccessControlAllowOrigin() {
|
||||
public @Nullable String getAccessControlAllowOrigin() {
|
||||
return getFieldValues(ACCESS_CONTROL_ALLOW_ORIGIN);
|
||||
}
|
||||
|
||||
@@ -726,8 +726,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Access-Control-Request-Method} request header.
|
||||
*/
|
||||
@Nullable
|
||||
public HttpMethod getAccessControlRequestMethod() {
|
||||
public @Nullable HttpMethod getAccessControlRequestMethod() {
|
||||
String requestMethod = getFirst(ACCESS_CONTROL_REQUEST_METHOD);
|
||||
if (requestMethod != null) {
|
||||
return HttpMethod.valueOf(requestMethod);
|
||||
@@ -896,8 +895,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Cache-Control} header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getCacheControl() {
|
||||
public @Nullable String getCacheControl() {
|
||||
return getFieldValues(CACHE_CONTROL);
|
||||
}
|
||||
|
||||
@@ -989,8 +987,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* if unknown
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public Locale getContentLanguage() {
|
||||
public @Nullable Locale getContentLanguage() {
|
||||
return getValuesAsList(CONTENT_LANGUAGE)
|
||||
.stream()
|
||||
.findFirst()
|
||||
@@ -1042,8 +1039,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* <p>Returns {@code null} when the {@code Content-Type} header is not set.
|
||||
* @throws InvalidMediaTypeException if the media type value cannot be parsed
|
||||
*/
|
||||
@Nullable
|
||||
public MediaType getContentType() {
|
||||
public @Nullable MediaType getContentType() {
|
||||
String value = getFirst(CONTENT_TYPE);
|
||||
return (StringUtils.hasLength(value) ? MediaType.parseMediaType(value) : null);
|
||||
}
|
||||
@@ -1102,8 +1098,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the entity tag of the body, as specified by the {@code ETag} header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getETag() {
|
||||
public @Nullable String getETag() {
|
||||
return getFirst(ETAG);
|
||||
}
|
||||
|
||||
@@ -1174,8 +1169,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* be {@code 0}.
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public InetSocketAddress getHost() {
|
||||
public @Nullable InetSocketAddress getHost() {
|
||||
String value = getFirst(HOST);
|
||||
if (value == null) {
|
||||
return null;
|
||||
@@ -1376,8 +1370,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* as specified by the {@code Location} header.
|
||||
* <p>Returns {@code null} when the location is unknown.
|
||||
*/
|
||||
@Nullable
|
||||
public URI getLocation() {
|
||||
public @Nullable URI getLocation() {
|
||||
String value = getFirst(LOCATION);
|
||||
return (value != null ? URI.create(value) : null);
|
||||
}
|
||||
@@ -1392,8 +1385,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Origin} header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getOrigin() {
|
||||
public @Nullable String getOrigin() {
|
||||
return getFirst(ORIGIN);
|
||||
}
|
||||
|
||||
@@ -1407,8 +1399,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Pragma} header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPragma() {
|
||||
public @Nullable String getPragma() {
|
||||
return getFirst(PRAGMA);
|
||||
}
|
||||
|
||||
@@ -1439,8 +1430,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
/**
|
||||
* Return the value of the {@code Upgrade} header.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUpgrade() {
|
||||
public @Nullable String getUpgrade() {
|
||||
return getFirst(UPGRADE);
|
||||
}
|
||||
|
||||
@@ -1532,8 +1522,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* @return the parsed date header, or {@code null} if none
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public ZonedDateTime getFirstZonedDateTime(String headerName) {
|
||||
public @Nullable ZonedDateTime getFirstZonedDateTime(String headerName) {
|
||||
return getFirstZonedDateTime(headerName, true);
|
||||
}
|
||||
|
||||
@@ -1548,8 +1537,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* in that case ({@code false})
|
||||
* @return the parsed date header, or {@code null} if none (or invalid)
|
||||
*/
|
||||
@Nullable
|
||||
private ZonedDateTime getFirstZonedDateTime(String headerName, boolean rejectInvalid) {
|
||||
private @Nullable ZonedDateTime getFirstZonedDateTime(String headerName, boolean rejectInvalid) {
|
||||
String headerValue = getFirst(headerName);
|
||||
if (headerValue == null) {
|
||||
// No header value sent at all
|
||||
@@ -1700,8 +1688,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* @return the combined result
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
protected String getFieldValues(String headerName) {
|
||||
protected @Nullable String getFieldValues(String headerName) {
|
||||
List<String> headerValues = get(headerName);
|
||||
return (headerValues != null ? toCommaDelimitedString(headerValues) : null);
|
||||
}
|
||||
@@ -1744,8 +1731,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* @return the first header value, or {@code null} if none
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFirst(String headerName) {
|
||||
public @Nullable String getFirst(String headerName) {
|
||||
return this.headers.getFirst(headerName);
|
||||
}
|
||||
|
||||
@@ -1818,8 +1804,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
return this.headers.get(key);
|
||||
}
|
||||
|
||||
@@ -2081,8 +2066,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
|
||||
private final Iterator<String> namesIterator;
|
||||
|
||||
@Nullable
|
||||
private String currentName;
|
||||
private @Nullable String currentName;
|
||||
|
||||
private CaseInsensitiveIterator(Iterator<String> namesIterator) {
|
||||
this.namesIterator = namesIterator;
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.http;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link RuntimeHintsRegistrar} implementation that makes sure mime types
|
||||
|
||||
@@ -24,10 +24,11 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourceRegion;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -234,8 +235,7 @@ public abstract class HttpRange {
|
||||
|
||||
private final long firstPos;
|
||||
|
||||
@Nullable
|
||||
private final Long lastPos;
|
||||
private final @Nullable Long lastPos;
|
||||
|
||||
public ByteRange(long firstPos, @Nullable Long lastPos) {
|
||||
assertPositions(firstPos, lastPos);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Enumeration of HTTP status codes.
|
||||
@@ -523,8 +523,7 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @return the corresponding {@code HttpStatus}, or {@code null} if not found
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public static HttpStatus resolve(int statusCode) {
|
||||
public static @Nullable HttpStatus resolve(int statusCode) {
|
||||
// Use cached VALUES instead of values() to prevent array allocation.
|
||||
for (HttpStatus status : VALUES) {
|
||||
if (status.value == statusCode) {
|
||||
@@ -591,8 +590,7 @@ public enum HttpStatus implements HttpStatusCode {
|
||||
* @return the corresponding {@code Series}, or {@code null} if not found
|
||||
* @since 5.1.3
|
||||
*/
|
||||
@Nullable
|
||||
public static Series resolve(int statusCode) {
|
||||
public static @Nullable Series resolve(int statusCode) {
|
||||
int seriesCode = statusCode / 100;
|
||||
for (Series series : values()) {
|
||||
if (series.value == seriesCode) {
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.http;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
|
||||
@@ -26,8 +26,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -56,19 +57,15 @@ public class ProblemDetail {
|
||||
|
||||
private URI type = BLANK_TYPE;
|
||||
|
||||
@Nullable
|
||||
private String title;
|
||||
private @Nullable String title;
|
||||
|
||||
private int status;
|
||||
|
||||
@Nullable
|
||||
private String detail;
|
||||
private @Nullable String detail;
|
||||
|
||||
@Nullable
|
||||
private URI instance;
|
||||
private @Nullable URI instance;
|
||||
|
||||
@Nullable
|
||||
private Map<String, Object> properties;
|
||||
private @Nullable Map<String, Object> properties;
|
||||
|
||||
|
||||
/**
|
||||
@@ -131,8 +128,7 @@ public class ProblemDetail {
|
||||
/**
|
||||
* Return the configured {@link #setTitle(String) problem title}.
|
||||
*/
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
public @Nullable String getTitle() {
|
||||
if (this.title == null) {
|
||||
HttpStatus httpStatus = HttpStatus.resolve(this.status);
|
||||
if (httpStatus != null) {
|
||||
@@ -178,8 +174,7 @@ public class ProblemDetail {
|
||||
/**
|
||||
* Return the configured {@link #setDetail(String) problem detail}.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDetail() {
|
||||
public @Nullable String getDetail() {
|
||||
return this.detail;
|
||||
}
|
||||
|
||||
@@ -196,8 +191,7 @@ public class ProblemDetail {
|
||||
/**
|
||||
* Return the configured {@link #setInstance(URI) problem instance}.
|
||||
*/
|
||||
@Nullable
|
||||
public URI getInstance() {
|
||||
public @Nullable URI getInstance() {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
@@ -239,8 +233,7 @@ public class ProblemDetail {
|
||||
* Otherwise, they are rendered as a {@code "properties"} sub-map.
|
||||
* @see org.springframework.http.converter.json.ProblemDetailJacksonMixin
|
||||
*/
|
||||
@Nullable
|
||||
public Map<String, Object> getProperties() {
|
||||
public @Nullable Map<String, Object> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -42,12 +43,10 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
|
||||
private static final long serialVersionUID = -8578554704772377436L;
|
||||
|
||||
@Nullable
|
||||
private MediaType cachedContentType;
|
||||
private @Nullable MediaType cachedContentType;
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("serial")
|
||||
private List<MediaType> cachedAccept;
|
||||
private @Nullable List<MediaType> cachedAccept;
|
||||
|
||||
|
||||
ReadOnlyHttpHeaders(MultiValueMap<String, String> headers) {
|
||||
@@ -56,8 +55,7 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public MediaType getContentType() {
|
||||
public @Nullable MediaType getContentType() {
|
||||
if (this.cachedContentType != null) {
|
||||
return this.cachedContentType;
|
||||
}
|
||||
@@ -86,8 +84,7 @@ class ReadOnlyHttpHeaders extends HttpHeaders {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> get(Object key) {
|
||||
public @Nullable List<String> get(Object key) {
|
||||
List<String> values = this.headers.get(key);
|
||||
return (values != null ? Collections.unmodifiableList(values) : null);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -66,14 +67,11 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class RequestEntity<T> extends HttpEntity<T> {
|
||||
|
||||
@Nullable
|
||||
private final HttpMethod method;
|
||||
private final @Nullable HttpMethod method;
|
||||
|
||||
@Nullable
|
||||
private final URI url;
|
||||
private final @Nullable URI url;
|
||||
|
||||
@Nullable
|
||||
private final Type type;
|
||||
private final @Nullable Type type;
|
||||
|
||||
/**
|
||||
* Constructor with method and URL but without body nor headers.
|
||||
@@ -152,8 +150,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||
* Return the HTTP method of the request.
|
||||
* @return the HTTP method as an {@code HttpMethod} enum value
|
||||
*/
|
||||
@Nullable
|
||||
public HttpMethod getMethod() {
|
||||
public @Nullable HttpMethod getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@@ -185,8 +182,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||
* @return the request's body type, or {@code null} if not known
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Type getType() {
|
||||
public @Nullable Type getType() {
|
||||
if (this.type == null) {
|
||||
T body = getBody();
|
||||
if (body != null) {
|
||||
@@ -552,17 +548,13 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@Nullable
|
||||
private final URI uri;
|
||||
private final @Nullable URI uri;
|
||||
|
||||
@Nullable
|
||||
private final String uriTemplate;
|
||||
private final @Nullable String uriTemplate;
|
||||
|
||||
@Nullable
|
||||
private final Object[] uriVarsArray;
|
||||
private final Object @Nullable [] uriVarsArray;
|
||||
|
||||
@Nullable
|
||||
private final Map<String, ?> uriVarsMap;
|
||||
private final @Nullable Map<String, ?> uriVarsMap;
|
||||
|
||||
DefaultBodyBuilder(HttpMethod method, URI url) {
|
||||
this.method = method;
|
||||
@@ -697,16 +689,14 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||
|
||||
private final String uriTemplate;
|
||||
|
||||
@Nullable
|
||||
private final Object[] uriVarsArray;
|
||||
private final Object @Nullable [] uriVarsArray;
|
||||
|
||||
@Nullable
|
||||
private final Map<String, ?> uriVarsMap;
|
||||
private final @Nullable Map<String, ?> uriVarsMap;
|
||||
|
||||
UriTemplateRequestEntity(
|
||||
@Nullable T body, @Nullable MultiValueMap<String, String> headers,
|
||||
@Nullable HttpMethod method, @Nullable Type type, String uriTemplate,
|
||||
@Nullable Object[] uriVarsArray, @Nullable Map<String, ?> uriVarsMap) {
|
||||
Object @Nullable [] uriVarsArray, @Nullable Map<String, ?> uriVarsMap) {
|
||||
|
||||
super(body, headers, method, null, type);
|
||||
this.uriTemplate = uriTemplate;
|
||||
@@ -718,13 +708,11 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||
return this.uriTemplate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object[] getVars() {
|
||||
public Object @Nullable [] getVars() {
|
||||
return this.uriVarsArray;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, ?> getVarsMap() {
|
||||
public @Nullable Map<String, ?> getVarsMap() {
|
||||
return this.uriVarsMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.http;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -37,11 +38,9 @@ public final class ResponseCookie extends HttpCookie {
|
||||
|
||||
private final Duration maxAge;
|
||||
|
||||
@Nullable
|
||||
private final String domain;
|
||||
private final @Nullable String domain;
|
||||
|
||||
@Nullable
|
||||
private final String path;
|
||||
private final @Nullable String path;
|
||||
|
||||
private final boolean secure;
|
||||
|
||||
@@ -49,8 +48,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
|
||||
private final boolean partitioned;
|
||||
|
||||
@Nullable
|
||||
private final String sameSite;
|
||||
private final @Nullable String sameSite;
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,16 +89,14 @@ public final class ResponseCookie extends HttpCookie {
|
||||
/**
|
||||
* Return the cookie "Domain" attribute, or {@code null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
public @Nullable String getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cookie "Path" attribute, or {@code null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPath() {
|
||||
public @Nullable String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@@ -135,8 +131,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
* @since 5.1
|
||||
* @see <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis#section-4.1.2.7">RFC6265 bis</a>
|
||||
*/
|
||||
@Nullable
|
||||
public String getSameSite() {
|
||||
public @Nullable String getSameSite() {
|
||||
return this.sameSite;
|
||||
}
|
||||
|
||||
@@ -403,18 +398,15 @@ public final class ResponseCookie extends HttpCookie {
|
||||
|
||||
private final String name;
|
||||
|
||||
@Nullable
|
||||
private String value;
|
||||
private @Nullable String value;
|
||||
|
||||
private final boolean lenient;
|
||||
|
||||
private Duration maxAge = Duration.ofSeconds(-1);
|
||||
|
||||
@Nullable
|
||||
private String domain;
|
||||
private @Nullable String domain;
|
||||
|
||||
@Nullable
|
||||
private String path;
|
||||
private @Nullable String path;
|
||||
|
||||
private boolean secure;
|
||||
|
||||
@@ -422,8 +414,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
|
||||
private boolean partitioned;
|
||||
|
||||
@Nullable
|
||||
private String sameSite;
|
||||
private @Nullable String sameSite;
|
||||
|
||||
public DefaultResponseCookieBuilder(String name, @Nullable String value, boolean lenient) {
|
||||
this.name = name;
|
||||
@@ -455,8 +446,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String initDomain(@Nullable String domain) {
|
||||
private @Nullable String initDomain(@Nullable String domain) {
|
||||
if (this.lenient && StringUtils.hasLength(domain)) {
|
||||
String str = domain.trim();
|
||||
if (str.startsWith("\"") && str.endsWith("\"")) {
|
||||
|
||||
@@ -25,7 +25,8 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -21,8 +21,9 @@ import java.io.OutputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -38,11 +39,9 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
|
||||
private boolean executed = false;
|
||||
|
||||
@Nullable
|
||||
private HttpHeaders readOnlyHeaders;
|
||||
private @Nullable HttpHeaders readOnlyHeaders;
|
||||
|
||||
@Nullable
|
||||
private Map<String, Object> attributes;
|
||||
private @Nullable Map<String, Object> attributes;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.springframework.http.client;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
|
||||
@@ -36,11 +37,9 @@ import org.springframework.util.FastByteArrayOutputStream;
|
||||
abstract class AbstractStreamingClientHttpRequest extends AbstractClientHttpRequest
|
||||
implements StreamingHttpOutputMessage {
|
||||
|
||||
@Nullable
|
||||
private Body body;
|
||||
private @Nullable Body body;
|
||||
|
||||
@Nullable
|
||||
private FastByteArrayOutputStream bodyStream;
|
||||
private @Nullable FastByteArrayOutputStream bodyStream;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,9 +20,10 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -36,8 +37,7 @@ final class BufferingClientHttpResponseWrapper implements ClientHttpResponse {
|
||||
|
||||
private final ClientHttpResponse response;
|
||||
|
||||
@Nullable
|
||||
private byte[] body;
|
||||
private byte @Nullable [] body;
|
||||
|
||||
|
||||
BufferingClientHttpResponseWrapper(ClientHttpResponse response) {
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.apache.hc.core5.http.HttpEntity;
|
||||
import org.apache.hc.core5.http.Method;
|
||||
import org.apache.hc.core5.http.io.entity.NullEntity;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -140,8 +140,7 @@ final class HttpComponentsClientHttpRequest extends AbstractStreamingClientHttpR
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContentType() {
|
||||
public @Nullable String getContentType() {
|
||||
return this.headers.getFirst(HttpHeaders.CONTENT_TYPE);
|
||||
}
|
||||
|
||||
@@ -166,14 +165,12 @@ final class HttpComponentsClientHttpRequest extends AbstractStreamingClientHttpR
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Supplier<List<? extends Header>> getTrailers() {
|
||||
public @Nullable Supplier<List<? extends Header>> getTrailers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContentEncoding() {
|
||||
public @Nullable String getContentEncoding() {
|
||||
return this.headers.getFirst(HttpHeaders.CONTENT_ENCODING);
|
||||
}
|
||||
|
||||
@@ -183,8 +180,7 @@ final class HttpComponentsClientHttpRequest extends AbstractStreamingClientHttpR
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> getTrailerNames() {
|
||||
public @Nullable Set<String> getTrailerNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,10 @@ import org.apache.hc.client5.http.protocol.HttpClientContext;
|
||||
import org.apache.hc.core5.http.ClassicHttpRequest;
|
||||
import org.apache.hc.core5.http.io.SocketConfig;
|
||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -66,8 +66,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
|
||||
private HttpClient httpClient;
|
||||
|
||||
@Nullable
|
||||
private BiFunction<HttpMethod, URI, HttpContext> httpContextFactory;
|
||||
private @Nullable BiFunction<HttpMethod, URI, HttpContext> httpContextFactory;
|
||||
|
||||
private long connectTimeout = -1;
|
||||
|
||||
@@ -269,8 +268,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* @since 4.2
|
||||
* @see #mergeRequestConfig(RequestConfig)
|
||||
*/
|
||||
@Nullable
|
||||
protected RequestConfig createRequestConfig(Object client) {
|
||||
protected @Nullable RequestConfig createRequestConfig(Object client) {
|
||||
if (client instanceof Configurable configurableClient) {
|
||||
RequestConfig clientRequestConfig = configurableClient.getConfig();
|
||||
return mergeRequestConfig(clientRequestConfig);
|
||||
@@ -354,8 +352,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* @param uri the URI
|
||||
* @return the http context
|
||||
*/
|
||||
@Nullable
|
||||
protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
|
||||
protected @Nullable HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
|
||||
return (this.httpContextFactory != null ? this.httpContextFactory.apply(httpMethod, uri) : null);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.io.InputStream;
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.HttpEntity;
|
||||
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.support.HttpComponentsHeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -44,8 +44,7 @@ final class HttpComponentsClientHttpResponse implements ClientHttpResponse {
|
||||
|
||||
private final ClassicHttpResponse httpResponse;
|
||||
|
||||
@Nullable
|
||||
private HttpHeaders headers;
|
||||
private @Nullable HttpHeaders headers;
|
||||
|
||||
|
||||
HttpComponentsClientHttpResponse(ClassicHttpResponse httpResponse) {
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link ClientHttpRequestFactory} wrapper with support for
|
||||
|
||||
@@ -38,9 +38,10 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -67,8 +68,7 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
|
||||
|
||||
private final Executor executor;
|
||||
|
||||
@Nullable
|
||||
private final Duration timeout;
|
||||
private final @Nullable Duration timeout;
|
||||
|
||||
|
||||
public JdkClientHttpRequest(HttpClient httpClient, URI uri, HttpMethod method, Executor executor,
|
||||
@@ -244,8 +244,7 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream wrapInputStream(HttpResponse<InputStream> response) {
|
||||
public @Nullable InputStream wrapInputStream(HttpResponse<InputStream> response) {
|
||||
InputStream body = response.body();
|
||||
if (body == null) {
|
||||
return body;
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.net.http.HttpClient;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -40,8 +41,7 @@ public class JdkClientHttpRequestFactory implements ClientHttpRequestFactory {
|
||||
|
||||
private final Executor executor;
|
||||
|
||||
@Nullable
|
||||
private Duration readTimeout;
|
||||
private @Nullable Duration readTimeout;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,10 +24,11 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.eclipse.jetty.client.InputStreamResponseListener;
|
||||
import org.eclipse.jetty.client.OutputStreamRequestContent;
|
||||
import org.eclipse.jetty.client.Request;
|
||||
import org.eclipse.jetty.client.Response;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
@@ -31,8 +33,6 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -276,11 +276,9 @@ public final class MultipartBodyBuilder {
|
||||
|
||||
private final String name;
|
||||
|
||||
@Nullable
|
||||
protected HttpHeaders headers;
|
||||
protected @Nullable HttpHeaders headers;
|
||||
|
||||
@Nullable
|
||||
protected final Object body;
|
||||
protected final @Nullable Object body;
|
||||
|
||||
public DefaultPartBuilder(String name, @Nullable HttpHeaders headers, @Nullable Object body) {
|
||||
this.name = name;
|
||||
@@ -381,8 +379,7 @@ public final class MultipartBodyBuilder {
|
||||
* Return the element type for the {@code Publisher} body.
|
||||
*/
|
||||
@Override
|
||||
@NonNull
|
||||
public ResolvableType getResolvableType() {
|
||||
public @NonNull ResolvableType getResolvableType() {
|
||||
return this.resolvableType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -136,8 +137,7 @@ final class OutputStreamPublisher<T> implements Flow.Publisher<T> {
|
||||
|
||||
private final AtomicReference<Object> parkedThread = new AtomicReference<>();
|
||||
|
||||
@Nullable
|
||||
private volatile Throwable error;
|
||||
private volatile @Nullable Throwable error;
|
||||
|
||||
private long produced;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.FlowAdapters;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -34,7 +35,6 @@ import reactor.netty.http.client.HttpClientRequest;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -53,8 +53,7 @@ final class ReactorClientHttpRequest extends AbstractStreamingClientHttpRequest
|
||||
|
||||
private final URI uri;
|
||||
|
||||
@Nullable
|
||||
private final Duration exchangeTimeout;
|
||||
private final @Nullable Duration exchangeTimeout;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,13 +24,13 @@ import java.util.function.Function;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.netty.resources.ConnectionProvider;
|
||||
import reactor.netty.resources.LoopResources;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -52,23 +52,17 @@ public class ReactorClientHttpRequestFactory implements ClientHttpRequestFactory
|
||||
client -> client.compress(true).responseTimeout(Duration.ofSeconds(10));
|
||||
|
||||
|
||||
@Nullable
|
||||
private final ReactorResourceFactory resourceFactory;
|
||||
private final @Nullable ReactorResourceFactory resourceFactory;
|
||||
|
||||
@Nullable
|
||||
private final Function<HttpClient, HttpClient> mapper;
|
||||
private final @Nullable Function<HttpClient, HttpClient> mapper;
|
||||
|
||||
@Nullable
|
||||
private Integer connectTimeout;
|
||||
private @Nullable Integer connectTimeout;
|
||||
|
||||
@Nullable
|
||||
private Duration readTimeout;
|
||||
private @Nullable Duration readTimeout;
|
||||
|
||||
@Nullable
|
||||
private Duration exchangeTimeout;
|
||||
private @Nullable Duration exchangeTimeout;
|
||||
|
||||
@Nullable
|
||||
private volatile HttpClient httpClient;
|
||||
private volatile @Nullable HttpClient httpClient;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.FlowAdapters;
|
||||
import reactor.netty.Connection;
|
||||
import reactor.netty.http.client.HttpClientResponse;
|
||||
@@ -27,7 +28,6 @@ import reactor.netty.http.client.HttpClientResponse;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.support.Netty4HeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -45,8 +45,7 @@ final class ReactorClientHttpResponse implements ClientHttpResponse {
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
@Nullable
|
||||
private volatile InputStream body;
|
||||
private volatile @Nullable InputStream body;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.netty.http.HttpResources;
|
||||
import reactor.netty.resources.ConnectionProvider;
|
||||
import reactor.netty.resources.LoopResources;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -55,18 +55,15 @@ public class ReactorResourceFactory
|
||||
|
||||
private boolean useGlobalResources = true;
|
||||
|
||||
@Nullable
|
||||
private Consumer<HttpResources> globalResourcesConsumer;
|
||||
private @Nullable Consumer<HttpResources> globalResourcesConsumer;
|
||||
|
||||
private Supplier<ConnectionProvider> connectionProviderSupplier = () -> ConnectionProvider.create("webflux", 500);
|
||||
|
||||
@Nullable
|
||||
private volatile ConnectionProvider connectionProvider;
|
||||
private volatile @Nullable ConnectionProvider connectionProvider;
|
||||
|
||||
private Supplier<LoopResources> loopResourcesSupplier = () -> LoopResources.create("webflux-http");
|
||||
|
||||
@Nullable
|
||||
private volatile LoopResources loopResources;
|
||||
private volatile @Nullable LoopResources loopResources;
|
||||
|
||||
private boolean manageConnectionProvider = false;
|
||||
|
||||
@@ -76,8 +73,7 @@ public class ReactorResourceFactory
|
||||
|
||||
private Duration shutdownTimeout = Duration.ofSeconds(LoopResources.DEFAULT_SHUTDOWN_TIMEOUT);
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
private @Nullable ApplicationContext applicationContext;
|
||||
|
||||
private volatile boolean running;
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,8 +24,9 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -42,8 +43,7 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory
|
||||
private static final int DEFAULT_CHUNK_SIZE = 4096;
|
||||
|
||||
|
||||
@Nullable
|
||||
private Proxy proxy;
|
||||
private @Nullable Proxy proxy;
|
||||
|
||||
private int chunkSize = DEFAULT_CHUNK_SIZE;
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -38,11 +39,9 @@ final class SimpleClientHttpResponse implements ClientHttpResponse {
|
||||
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
@Nullable
|
||||
private HttpHeaders headers;
|
||||
private @Nullable HttpHeaders headers;
|
||||
|
||||
@Nullable
|
||||
private InputStream responseStream;
|
||||
private @Nullable InputStream responseStream;
|
||||
|
||||
|
||||
SimpleClientHttpResponse(HttpURLConnection connection) {
|
||||
|
||||
@@ -32,9 +32,9 @@ import java.util.function.Function;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.Exceptions;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -89,18 +89,15 @@ final class SubscriberInputStream<T> extends InputStream implements Flow.Subscri
|
||||
|
||||
private int consumed;
|
||||
|
||||
@Nullable
|
||||
private byte[] available;
|
||||
private byte @Nullable [] available;
|
||||
|
||||
private int position;
|
||||
|
||||
@Nullable
|
||||
private Flow.Subscription subscription;
|
||||
private Flow.@Nullable Subscription subscription;
|
||||
|
||||
private boolean done;
|
||||
|
||||
@Nullable
|
||||
private Throwable error;
|
||||
private @Nullable Throwable error;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.springframework.http.client.observation;
|
||||
|
||||
import io.micrometer.observation.transport.RequestReplySenderContext;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Context that holds information for metadata collection during the
|
||||
@@ -34,8 +34,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class ClientRequestObservationContext extends RequestReplySenderContext<ClientHttpRequest, ClientHttpResponse> {
|
||||
|
||||
@Nullable
|
||||
private String uriTemplate;
|
||||
private @Nullable String uriTemplate;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,8 +63,7 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C
|
||||
/**
|
||||
* Return the URI template used for the current client exchange, {@code null} if none was used.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUriTemplate() {
|
||||
public @Nullable String getUriTemplate() {
|
||||
return this.uriTemplate;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import io.micrometer.common.KeyValue;
|
||||
import io.micrometer.common.KeyValues;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.client.observation.ClientHttpObservationDocumentation.HighCardinalityKeyNames;
|
||||
import org.springframework.http.client.observation.ClientHttpObservationDocumentation.LowCardinalityKeyNames;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContextualName(ClientRequestObservationContext context) {
|
||||
public @Nullable String getContextualName(ClientRequestObservationContext context) {
|
||||
ClientHttpRequest request = context.getCarrier();
|
||||
return (request != null ? "http " + request.getMethod().name().toLowerCase(Locale.ROOT) : null);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* This package provides support for client HTTP
|
||||
* {@link io.micrometer.observation.Observation}.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.client.observation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* contains the {@code ClientHttpRequest} and {@code ClientHttpResponse},
|
||||
* as well as a basic implementation of these interfaces.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -24,13 +24,13 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -64,8 +64,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
|
||||
private final List<Supplier<? extends Publisher<Void>>> commitActions = new ArrayList<>(4);
|
||||
|
||||
@Nullable
|
||||
private HttpHeaders readOnlyHeaders;
|
||||
private @Nullable HttpHeaders readOnlyHeaders;
|
||||
|
||||
|
||||
public AbstractClientHttpRequest() {
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.apache.hc.core5.http.message.BasicHttpRequest;
|
||||
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
|
||||
import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
|
||||
import org.apache.hc.core5.reactive.ReactiveEntityProducer;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -40,7 +41,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.support.HttpComponentsHeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -59,8 +59,7 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
|
||||
private final HttpClientContext context;
|
||||
|
||||
@Nullable
|
||||
private Flux<ByteBuffer> byteBufferFlux;
|
||||
private @Nullable Flux<ByteBuffer> byteBufferFlux;
|
||||
|
||||
private transient long contentLength = -1;
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,7 @@ public class JdkClientHttpConnector implements ClientHttpConnector {
|
||||
|
||||
private DataBufferFactory bufferFactory = DefaultDataBufferFactory.sharedInstance;
|
||||
|
||||
@Nullable
|
||||
private Duration readTimeout;
|
||||
private @Nullable Duration readTimeout;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.concurrent.Flow;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.adapter.JdkFlowAdapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -37,7 +38,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.adapter.JdkFlowAdapter;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -37,7 +38,6 @@ import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -41,8 +42,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JdkHttpClientResourceFactory implements InitializingBean, DisposableBean {
|
||||
|
||||
@Nullable
|
||||
private Executor executor;
|
||||
private @Nullable Executor executor;
|
||||
|
||||
private String threadPrefix = "jdk-http";
|
||||
|
||||
@@ -62,8 +62,7 @@ public class JdkHttpClientResourceFactory implements InitializingBean, Disposabl
|
||||
/**
|
||||
* Return the configured {@link Executor}.
|
||||
*/
|
||||
@Nullable
|
||||
public Executor getExecutor() {
|
||||
public @Nullable Executor getExecutor() {
|
||||
return this.executor;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.function.Function;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.Request;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.JettyDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.reactive.client.ReactiveResponse;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.support.JettyHeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -77,8 +77,7 @@ class JettyClientHttpResponse extends AbstractClientHttpResponse {
|
||||
return CollectionUtils.unmodifiableMultiValueMap(result);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String parseSameSite(String headerValue) {
|
||||
private static @Nullable String parseSameSite(String headerValue) {
|
||||
Matcher matcher = SAME_SITE_PATTERN.matcher(headerValue);
|
||||
return (matcher.matches() ? matcher.group(1) : null);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -46,14 +46,11 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JettyResourceFactory implements InitializingBean, DisposableBean {
|
||||
|
||||
@Nullable
|
||||
private Executor executor;
|
||||
private @Nullable Executor executor;
|
||||
|
||||
@Nullable
|
||||
private ByteBufferPool byteBufferPool;
|
||||
private @Nullable ByteBufferPool byteBufferPool;
|
||||
|
||||
@Nullable
|
||||
private Scheduler scheduler;
|
||||
private @Nullable Scheduler scheduler;
|
||||
|
||||
private String threadPrefix = "jetty-http";
|
||||
|
||||
@@ -100,24 +97,21 @@ public class JettyResourceFactory implements InitializingBean, DisposableBean {
|
||||
/**
|
||||
* Return the configured {@link Executor}.
|
||||
*/
|
||||
@Nullable
|
||||
public Executor getExecutor() {
|
||||
public @Nullable Executor getExecutor() {
|
||||
return this.executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configured {@link ByteBufferPool}.
|
||||
*/
|
||||
@Nullable
|
||||
public ByteBufferPool getByteBufferPool() {
|
||||
public @Nullable ByteBufferPool getByteBufferPool() {
|
||||
return this.byteBufferPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configured {@link Scheduler}.
|
||||
*/
|
||||
@Nullable
|
||||
public Scheduler getScheduler() {
|
||||
public @Nullable Scheduler getScheduler() {
|
||||
return this.scheduler;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.function.Function;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.netty.NettyOutbound;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
@@ -34,7 +35,6 @@ import reactor.netty.resources.LoopResources;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ReactorResourceFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -64,14 +64,11 @@ public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLif
|
||||
private static final Function<HttpClient, HttpClient> defaultInitializer = client -> client.compress(true);
|
||||
|
||||
|
||||
@Nullable
|
||||
private final ReactorResourceFactory resourceFactory;
|
||||
private final @Nullable ReactorResourceFactory resourceFactory;
|
||||
|
||||
@Nullable
|
||||
private final Function<HttpClient, HttpClient> mapper;
|
||||
private final @Nullable Function<HttpClient, HttpClient> mapper;
|
||||
|
||||
@Nullable
|
||||
private volatile HttpClient httpClient;
|
||||
private volatile @Nullable HttpClient httpClient;
|
||||
|
||||
private boolean lazyStart = false;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.handler.codec.http.cookie.Cookie;
|
||||
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.netty.ChannelOperationsId;
|
||||
import reactor.netty.Connection;
|
||||
@@ -38,7 +39,6 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.support.Netty4HeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -152,8 +152,7 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
|
||||
return CollectionUtils.unmodifiableMultiValueMap(result);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getSameSite(Cookie cookie) {
|
||||
private static @Nullable String getSameSite(Cookie cookie) {
|
||||
if (cookie instanceof DefaultCookie defaultCookie && defaultCookie.sameSite() != null) {
|
||||
return defaultCookie.sameSite().name();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty5.handler.codec.http.headers.DefaultHttpSetCookie;
|
||||
import io.netty5.handler.codec.http.headers.HttpSetCookie;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.netty5.ChannelOperationsId;
|
||||
import reactor.netty5.Connection;
|
||||
@@ -37,7 +38,6 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.support.Netty5HeadersAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -136,8 +136,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
|
||||
return CollectionUtils.unmodifiableMultiValueMap(result);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String toString(@Nullable CharSequence value) {
|
||||
private static @Nullable String toString(@Nullable CharSequence value) {
|
||||
return (value != null ? value.toString() : null);
|
||||
}
|
||||
|
||||
@@ -145,8 +144,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
|
||||
return (value != null ? value : -1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getSameSite(HttpSetCookie cookie) {
|
||||
private static @Nullable String getSameSite(HttpSetCookie cookie) {
|
||||
if (cookie instanceof DefaultHttpSetCookie defaultCookie && defaultCookie.sameSite() != null) {
|
||||
return defaultCookie.sameSite().name();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.netty5.http.HttpResources;
|
||||
import reactor.netty5.resources.ConnectionProvider;
|
||||
import reactor.netty5.resources.LoopResources;
|
||||
@@ -27,7 +28,6 @@ import reactor.netty5.resources.LoopResources;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.http.client.ReactorResourceFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -47,18 +47,15 @@ public class ReactorNetty2ResourceFactory implements InitializingBean, Disposabl
|
||||
|
||||
private boolean useGlobalResources = true;
|
||||
|
||||
@Nullable
|
||||
private Consumer<HttpResources> globalResourcesConsumer;
|
||||
private @Nullable Consumer<HttpResources> globalResourcesConsumer;
|
||||
|
||||
private Supplier<ConnectionProvider> connectionProviderSupplier = () -> ConnectionProvider.create("webflux", 500);
|
||||
|
||||
@Nullable
|
||||
private ConnectionProvider connectionProvider;
|
||||
private @Nullable ConnectionProvider connectionProvider;
|
||||
|
||||
private Supplier<LoopResources> loopResourcesSupplier = () -> LoopResources.create("webflux-http");
|
||||
|
||||
@Nullable
|
||||
private LoopResources loopResources;
|
||||
private @Nullable LoopResources loopResources;
|
||||
|
||||
private boolean manageConnectionProvider = false;
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
* {@link org.springframework.http.client.reactive.ClientHttpResponse} as well as a
|
||||
* {@link org.springframework.http.client.reactive.ClientHttpConnector}.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.client.reactive;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -19,12 +19,13 @@ package org.springframework.http.client.support;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link ClientHttpRequestInterceptor} to apply a given HTTP Basic Authentication
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.springframework.http.client.support;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -46,8 +47,7 @@ public abstract class InterceptingHttpAccessor extends HttpAccessor {
|
||||
|
||||
private final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private volatile ClientHttpRequestFactory interceptingRequestFactory;
|
||||
private volatile @Nullable ClientHttpRequestFactory interceptingRequestFactory;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,9 +20,10 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -37,13 +38,11 @@ public class ProxyFactoryBean implements FactoryBean<Proxy>, InitializingBean {
|
||||
|
||||
private Proxy.Type type = Proxy.Type.HTTP;
|
||||
|
||||
@Nullable
|
||||
private String hostname;
|
||||
private @Nullable String hostname;
|
||||
|
||||
private int port = -1;
|
||||
|
||||
@Nullable
|
||||
private Proxy proxy;
|
||||
private @Nullable Proxy proxy;
|
||||
|
||||
|
||||
/**
|
||||
@@ -83,8 +82,7 @@ public class ProxyFactoryBean implements FactoryBean<Proxy>, InitializingBean {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Proxy getObject() {
|
||||
public @Nullable Proxy getObject() {
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* This package provides generic HTTP support classes,
|
||||
* to be used by higher-level classes like RestTemplate.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.client.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.springframework.http.codec;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.codec.Decoder;
|
||||
import org.springframework.core.codec.Encoder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Defines a common interface for configuring either client or server HTTP
|
||||
@@ -396,15 +397,13 @@ public interface CodecConfigurer {
|
||||
* Get the configured limit on the number of bytes that can be buffered whenever
|
||||
* the input stream needs to be aggregated.
|
||||
*/
|
||||
@Nullable
|
||||
Integer maxInMemorySize();
|
||||
@Nullable Integer maxInMemorySize();
|
||||
|
||||
/**
|
||||
* Whether to log form data at DEBUG level, and headers at TRACE level.
|
||||
* Both may contain sensitive information.
|
||||
*/
|
||||
@Nullable
|
||||
Boolean isEnableLoggingRequestDetails();
|
||||
@Nullable Boolean isEnableLoggingRequestDetails();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.springframework.http.codec;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
import org.springframework.http.codec.support.DefaultClientCodecConfigurer;
|
||||
import org.springframework.http.codec.support.DefaultServerCodecConfigurer;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link RuntimeHintsRegistrar} implementation that registers runtime hints for
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -33,7 +34,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -118,8 +118,7 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> {
|
||||
* @param inputMessage the HTTP message
|
||||
* @return the MediaType, possibly {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
protected MediaType getContentType(HttpMessage inputMessage) {
|
||||
protected @Nullable MediaType getContentType(HttpMessage inputMessage) {
|
||||
MediaType contentType = inputMessage.getHeaders().getContentType();
|
||||
return (contentType != null ? contentType : MediaType.APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -35,7 +36,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -63,8 +63,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
|
||||
private final List<MediaType> mediaTypes;
|
||||
|
||||
@Nullable
|
||||
private final MediaType defaultMediaType;
|
||||
private final @Nullable MediaType defaultMediaType;
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,8 +85,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static MediaType initDefaultMediaType(List<MediaType> mediaTypes) {
|
||||
private static @Nullable MediaType initDefaultMediaType(List<MediaType> mediaTypes) {
|
||||
return mediaTypes.stream().filter(MediaType::isConcrete).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@@ -153,8 +151,7 @@ public class EncoderHttpMessageWriter<T> implements HttpMessageWriter<T> {
|
||||
return message.writeWith(body);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MediaType updateContentType(ReactiveHttpOutputMessage message, @Nullable MediaType mediaType) {
|
||||
private @Nullable MediaType updateContentType(ReactiveHttpOutputMessage message, @Nullable MediaType mediaType) {
|
||||
MediaType result = message.getHeaders().getContentType();
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -33,7 +34,6 @@ import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -33,7 +34,6 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
||||
@@ -19,13 +19,14 @@ package org.springframework.http.codec;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.Encoder;
|
||||
import org.springframework.core.codec.Hints;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@code Encoder} exposing extra methods relevant in the context
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -29,7 +30,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy for reading from a {@link ReactiveHttpInputMessage} and decoding
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -29,7 +30,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy for encoding a stream of objects of type {@code <T>} and writing
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import kotlinx.serialization.BinaryFormat;
|
||||
import kotlinx.serialization.KSerializer;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.core.codec.ByteArrayDecoder;
|
||||
import org.springframework.core.codec.Decoder;
|
||||
import org.springframework.core.codec.DecodingException;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import kotlinx.serialization.BinaryFormat;
|
||||
import kotlinx.serialization.KSerializer;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.core.codec.Encoder;
|
||||
import org.springframework.core.codec.EncodingException;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import kotlinx.serialization.KSerializer;
|
||||
import kotlinx.serialization.StringFormat;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.core.codec.Decoder;
|
||||
import org.springframework.core.codec.DecodingException;
|
||||
import org.springframework.core.codec.StringDecoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
|
||||
import kotlinx.serialization.KSerializer;
|
||||
import kotlinx.serialization.StringFormat;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -36,7 +37,6 @@ import org.springframework.core.codec.EncodingException;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,11 +33,11 @@ import kotlinx.serialization.SerialFormat;
|
||||
import kotlinx.serialization.SerializersKt;
|
||||
import kotlinx.serialization.descriptors.PolymorphicKind;
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.MimeType;
|
||||
@@ -126,8 +126,7 @@ public abstract class KotlinSerializationSupport<T extends SerialFormat> {
|
||||
* @param resolvableType the type to find a serializer for
|
||||
* @return a resolved serializer for the given type, or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
protected final KSerializer<Object> serializer(ResolvableType resolvableType) {
|
||||
protected final @Nullable KSerializer<Object> serializer(ResolvableType resolvableType) {
|
||||
if (resolvableType.getSource() instanceof MethodParameter parameter) {
|
||||
Method method = parameter.getMethod();
|
||||
Assert.notNull(method, "Method must not be null");
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -47,7 +48,6 @@ import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.ZeroCopyHttpOutputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
/**
|
||||
@@ -188,8 +188,7 @@ public class ResourceHttpMessageWriter implements HttpMessageWriter<Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Mono<Void> zeroCopy(Resource resource, @Nullable ResourceRegion region,
|
||||
private static @Nullable Mono<Void> zeroCopy(Resource resource, @Nullable ResourceRegion region,
|
||||
ReactiveHttpOutputMessage message, Map<String, Object> hints) {
|
||||
|
||||
if (message instanceof ZeroCopyHttpOutputMessage zeroCopyHttpOutputMessage && resource.isFile()) {
|
||||
|
||||
@@ -18,7 +18,8 @@ package org.springframework.http.codec;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -36,20 +37,15 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public final class ServerSentEvent<T> {
|
||||
|
||||
@Nullable
|
||||
private final String id;
|
||||
private final @Nullable String id;
|
||||
|
||||
@Nullable
|
||||
private final String event;
|
||||
private final @Nullable String event;
|
||||
|
||||
@Nullable
|
||||
private final Duration retry;
|
||||
private final @Nullable Duration retry;
|
||||
|
||||
@Nullable
|
||||
private final String comment;
|
||||
private final @Nullable String comment;
|
||||
|
||||
@Nullable
|
||||
private final T data;
|
||||
private final @Nullable T data;
|
||||
|
||||
|
||||
private ServerSentEvent(@Nullable String id, @Nullable String event, @Nullable Duration retry,
|
||||
@@ -66,40 +62,35 @@ public final class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the {@code id} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String id() {
|
||||
public @Nullable String id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code event} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String event() {
|
||||
public @Nullable String event() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code retry} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public Duration retry() {
|
||||
public @Nullable Duration retry() {
|
||||
return this.retry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the comment of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String comment() {
|
||||
public @Nullable String comment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code data} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public T data() {
|
||||
public @Nullable T data() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@@ -229,20 +220,15 @@ public final class ServerSentEvent<T> {
|
||||
|
||||
private static class BuilderImpl<T> implements Builder<T> {
|
||||
|
||||
@Nullable
|
||||
private String id;
|
||||
private @Nullable String id;
|
||||
|
||||
@Nullable
|
||||
private String event;
|
||||
private @Nullable String event;
|
||||
|
||||
@Nullable
|
||||
private Duration retry;
|
||||
private @Nullable Duration retry;
|
||||
|
||||
@Nullable
|
||||
private String comment;
|
||||
private @Nullable String comment;
|
||||
|
||||
@Nullable
|
||||
private T data;
|
||||
private @Nullable T data;
|
||||
|
||||
public BuilderImpl() {
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -34,7 +35,6 @@ import org.springframework.core.io.buffer.DataBufferLimitException;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Reader that supports a stream of {@link ServerSentEvent ServerSentEvents} and also plain
|
||||
@@ -50,8 +50,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
||||
private static final ResolvableType STRING_TYPE = ResolvableType.forClass(String.class);
|
||||
|
||||
|
||||
@Nullable
|
||||
private final Decoder<?> decoder;
|
||||
private final @Nullable Decoder<?> decoder;
|
||||
|
||||
private final StringDecoder lineDecoder = StringDecoder.textPlainOnly();
|
||||
|
||||
@@ -76,8 +75,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
||||
/**
|
||||
* Return the configured {@code Decoder}.
|
||||
*/
|
||||
@Nullable
|
||||
public Decoder<?> getDecoder() {
|
||||
public @Nullable Decoder<?> getDecoder() {
|
||||
return this.decoder;
|
||||
}
|
||||
|
||||
@@ -137,9 +135,8 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("NullAway")
|
||||
private Object buildEvent(List<String> lines, ResolvableType valueType, boolean shouldWrap,
|
||||
private @Nullable Object buildEvent(List<String> lines, ResolvableType valueType, boolean shouldWrap,
|
||||
Map<String, Object> hints) {
|
||||
|
||||
ServerSentEvent.Builder<Object> sseBuilder = (shouldWrap ? ServerSentEvent.builder() : null);
|
||||
@@ -191,8 +188,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object decodeData(StringBuilder data, ResolvableType dataType, Map<String, Object> hints) {
|
||||
private @Nullable Object decodeData(StringBuilder data, ResolvableType dataType, Map<String, Object> hints) {
|
||||
if (String.class == dataType.resolve()) {
|
||||
return data.substring(0, data.length() - 1);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -38,7 +39,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -59,8 +59,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
||||
private static final Log logger = HttpLogging.forLogName(ServerSentEventHttpMessageWriter.class);
|
||||
|
||||
|
||||
@Nullable
|
||||
private final Encoder<?> encoder;
|
||||
private final @Nullable Encoder<?> encoder;
|
||||
|
||||
|
||||
/**
|
||||
@@ -84,8 +83,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
||||
/**
|
||||
* Return the configured {@code Encoder}, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Encoder<?> getEncoder() {
|
||||
public @Nullable Encoder<?> getEncoder() {
|
||||
return this.encoder;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -28,7 +29,6 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.json.AbstractJackson2Decoder;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -29,7 +30,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.json.AbstractJackson2Encoder;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* CBOR encoder and decoder support.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.codec.cbor;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
|
||||
import com.fasterxml.jackson.databind.util.TokenBuffer;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -49,7 +50,6 @@ import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.codec.HttpMessageDecoder;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
@@ -257,8 +257,7 @@ public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport imple
|
||||
return reader;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Class<?> getContextClass(@Nullable ResolvableType elementType) {
|
||||
private @Nullable Class<?> getContextClass(@Nullable ResolvableType elementType) {
|
||||
MethodParameter param = (elementType != null ? getParameter(elementType) : null);
|
||||
return (param != null ? param.getContainingClass() : null);
|
||||
}
|
||||
@@ -307,8 +306,7 @@ public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport imple
|
||||
// Jackson2CodecSupport
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected <A extends Annotation> A getAnnotation(MethodParameter parameter, Class<A> annotType) {
|
||||
protected <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType) {
|
||||
return parameter.getParameterAnnotation(annotType);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.SequenceWriter;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
|
||||
import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -53,7 +54,6 @@ import org.springframework.http.codec.HttpMessageEncoder;
|
||||
import org.springframework.http.converter.json.MappingJacksonValue;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
@@ -371,8 +371,7 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple
|
||||
* streaming} mime types.
|
||||
* @since 5.3
|
||||
*/
|
||||
@Nullable
|
||||
protected byte[] getStreamingMediaTypeSeparator(@Nullable MimeType mimeType) {
|
||||
protected byte @Nullable [] getStreamingMediaTypeSeparator(@Nullable MimeType mimeType) {
|
||||
for (MediaType streamingMediaType : this.streamingMediaTypes) {
|
||||
if (streamingMediaType.isCompatibleWith(mimeType)) {
|
||||
return NEWLINE_SEPARATOR;
|
||||
@@ -427,8 +426,7 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple
|
||||
// Jackson2CodecSupport
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected <A extends Annotation> A getAnnotation(MethodParameter parameter, Class<A> annotType) {
|
||||
protected <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType) {
|
||||
return parameter.getMethodAnnotation(annotType);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -41,7 +42,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ProblemDetail;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
@@ -85,8 +85,7 @@ public abstract class Jackson2CodecSupport {
|
||||
|
||||
private ObjectMapper defaultObjectMapper;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, Map<MimeType, ObjectMapper>> objectMapperRegistrations;
|
||||
private @Nullable Map<Class<?>, Map<MimeType, ObjectMapper>> objectMapperRegistrations;
|
||||
|
||||
private final List<MimeType> mimeTypes;
|
||||
|
||||
@@ -150,8 +149,7 @@ public abstract class Jackson2CodecSupport {
|
||||
* or empty if in case of no registrations for the given class.
|
||||
* @since 5.3.4
|
||||
*/
|
||||
@Nullable
|
||||
public Map<MimeType, ObjectMapper> getObjectMappersForType(Class<?> clazz) {
|
||||
public @Nullable Map<MimeType, ObjectMapper> getObjectMappersForType(Class<?> clazz) {
|
||||
for (Map.Entry<Class<?>, Map<MimeType, ObjectMapper>> entry : getObjectMapperRegistrations().entrySet()) {
|
||||
if (entry.getKey().isAssignableFrom(clazz)) {
|
||||
return entry.getValue();
|
||||
@@ -252,13 +250,11 @@ public abstract class Jackson2CodecSupport {
|
||||
return Hints.none();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected MethodParameter getParameter(ResolvableType type) {
|
||||
protected @Nullable MethodParameter getParameter(ResolvableType type) {
|
||||
return (type.getSource() instanceof MethodParameter methodParameter ? methodParameter : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract <A extends Annotation> A getAnnotation(MethodParameter parameter, Class<A> annotType);
|
||||
protected abstract <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType);
|
||||
|
||||
/**
|
||||
* Select an ObjectMapper to use, either the main ObjectMapper or another
|
||||
@@ -266,8 +262,7 @@ public abstract class Jackson2CodecSupport {
|
||||
* {@link #registerObjectMappersForType(Class, Consumer)}.
|
||||
* @since 5.3.4
|
||||
*/
|
||||
@Nullable
|
||||
protected ObjectMapper selectObjectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType) {
|
||||
protected @Nullable ObjectMapper selectObjectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType) {
|
||||
if (targetMimeType == null || CollectionUtils.isEmpty(this.objectMapperRegistrations)) {
|
||||
return this.defaultObjectMapper;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -31,7 +32,6 @@ import org.springframework.core.codec.CharBufferDecoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
@@ -51,8 +51,7 @@ public class Jackson2JsonEncoder extends AbstractJackson2Encoder {
|
||||
Collections.singletonList(MediaType.APPLICATION_PROBLEM_JSON);
|
||||
|
||||
|
||||
@Nullable
|
||||
private final PrettyPrinter ssePrettyPrinter;
|
||||
private final @Nullable PrettyPrinter ssePrettyPrinter;
|
||||
|
||||
|
||||
public Jackson2JsonEncoder() {
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
@@ -65,9 +65,8 @@ public class Jackson2SmileEncoder extends AbstractJackson2Encoder {
|
||||
* streaming} mime types.
|
||||
* @since 5.3
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
protected byte[] getStreamingMediaTypeSeparator(@Nullable MimeType mimeType) {
|
||||
protected byte @Nullable [] getStreamingMediaTypeSeparator(@Nullable MimeType mimeType) {
|
||||
for (MediaType streamingMediaType : getStreamingMediaTypes()) {
|
||||
if (streamingMediaType.isCompatibleWith(mimeType)) {
|
||||
return STREAM_SEPARATOR;
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kotlinx.serialization.json.Json;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.KotlinSerializationStringEncoder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* JSON encoder and decoder support.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.http.codec.json;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
@@ -37,7 +38,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.LoggingCodecSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -66,8 +66,7 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
|
||||
|
||||
private int maxParts = -1;
|
||||
|
||||
@Nullable
|
||||
private Scheduler blockingOperationScheduler;
|
||||
private @Nullable Scheduler blockingOperationScheduler;
|
||||
|
||||
private FileStorage fileStorage = FileStorage.tempDirectory(this::getBlockingOperationScheduler);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -32,7 +33,6 @@ import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MediaTypeFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ package org.springframework.http.codec.multipart;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -32,7 +33,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.LoggingCodecSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -47,7 +48,6 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
|
||||
import org.springframework.http.codec.FormHttpMessageWriter;
|
||||
import org.springframework.http.codec.HttpMessageWriter;
|
||||
import org.springframework.http.codec.ResourceHttpMessageWriter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -81,8 +81,7 @@ public class MultipartHttpMessageWriter extends MultipartWriterSupport
|
||||
|
||||
private final Supplier<List<HttpMessageWriter<?>>> partWritersSupplier;
|
||||
|
||||
@Nullable
|
||||
private final HttpMessageWriter<MultiValueMap<String, String>> formWriter;
|
||||
private final @Nullable HttpMessageWriter<MultiValueMap<String, String>> formWriter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -154,8 +153,7 @@ public class MultipartHttpMessageWriter extends MultipartWriterSupport
|
||||
* Return the configured form writer.
|
||||
* @since 5.1.13
|
||||
*/
|
||||
@Nullable
|
||||
public HttpMessageWriter<MultiValueMap<String, String>> getFormWriter() {
|
||||
public @Nullable HttpMessageWriter<MultiValueMap<String, String>> getFormWriter() {
|
||||
return this.formWriter;
|
||||
}
|
||||
|
||||
@@ -315,8 +313,7 @@ public class MultipartHttpMessageWriter extends MultipartWriterSupport
|
||||
|
||||
private final AtomicBoolean committed = new AtomicBoolean();
|
||||
|
||||
@Nullable
|
||||
private Flux<DataBuffer> body;
|
||||
private @Nullable Flux<DataBuffer> body;
|
||||
|
||||
public MultipartHttpOutputMessage(DataBufferFactory bufferFactory) {
|
||||
this.bufferFactory = bufferFactory;
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.publisher.BaseSubscriber;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -41,7 +42,6 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferLimitException;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subscribes to a buffer stream and produces a flux of {@link Token} instances.
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Various static utility methods for dealing with multipart parsing.
|
||||
@@ -50,8 +51,7 @@ abstract class MultipartUtils {
|
||||
return StandardCharsets.UTF_8;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static byte[] boundary(HttpMessage message, Charset headersCharset) {
|
||||
public static byte @Nullable [] boundary(HttpMessage message, Charset headersCharset) {
|
||||
MediaType contentType = message.getHeaders().getContentType();
|
||||
if (contentType != null) {
|
||||
String boundary = contentType.getParameter("boundary");
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.LoggingCodecSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -39,7 +40,6 @@ import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.LoggingCodecSupport;
|
||||
import org.springframework.http.codec.multipart.MultipartParser.HeadersToken;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user