Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi annotations that leverage JSR 305 (dormant but available via Findbugs jsr305 dependency and already used by libraries like OkHttp) meta-annotations to specify explicitly null-safety of Spring Framework parameters and return values. In order to avoid adding too much annotations, the default is set at package level with @NonNullApi and @Nullable annotations are added when needed at parameter or return value level. These annotations are intended to be used on Spring Framework itself but also by other Spring projects. @Nullable annotations have been introduced based on Javadoc and search of patterns like "return null;". It is expected that nullability of Spring Framework API will be polished with complementary commits. In practice, this will make the whole Spring Framework API null-safe for Kotlin projects (when KT-10942 will be fixed) since Kotlin will be able to leverage these annotations to know if a parameter or a return value is nullable or not. But this is also useful for Java developers as well since IntelliJ IDEA, for example, also understands these annotations to generate warnings when unsafe nullable usages are detected. Issue: SPR-15540
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.http;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -246,6 +247,7 @@ public class CacheControl {
|
||||
* Return the "Cache-Control" header value.
|
||||
* @return {@code null} if no directive was added, or the header value otherwise
|
||||
*/
|
||||
@Nullable
|
||||
public String getHeaderValue() {
|
||||
StringBuilder ccValue = new StringBuilder();
|
||||
if (this.maxAge != -1) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -61,6 +62,7 @@ public class ContentDisposition {
|
||||
* Return the disposition type, like for example {@literal inline}, {@literal attachment},
|
||||
* {@literal form-data}, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
@@ -68,6 +70,7 @@ public class ContentDisposition {
|
||||
/**
|
||||
* Return the value of the {@literal name} parameter, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -76,6 +79,7 @@ public class ContentDisposition {
|
||||
* Return the value of the {@literal filename} parameter (or the value of the
|
||||
* {@literal filename*} one decoded as defined in the RFC 5987), or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public String getFilename() {
|
||||
return this.filename;
|
||||
}
|
||||
@@ -83,6 +87,7 @@ public class ContentDisposition {
|
||||
/**
|
||||
* Return the charset defined in {@literal filename*} parameter, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public Charset getCharset() {
|
||||
return this.charset;
|
||||
}
|
||||
@@ -90,6 +95,7 @@ public class ContentDisposition {
|
||||
/**
|
||||
* Return the value of the {@literal size} parameter, or {@code null} if not defined.
|
||||
*/
|
||||
@Nullable
|
||||
public Long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -740,7 +741,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* @see #setContentDisposition(ContentDisposition)
|
||||
* @see #getContentDisposition()
|
||||
*/
|
||||
public void setContentDispositionFormData(String name, String filename) {
|
||||
public void setContentDispositionFormData(String name, @Nullable String filename) {
|
||||
setContentDispositionFormData(name, filename, null);
|
||||
}
|
||||
|
||||
@@ -756,7 +757,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* @see #getContentDisposition()
|
||||
* @see <a href="https://tools.ietf.org/html/rfc7230#section-3.2.4">RFC 7230 Section 3.2.4</a>
|
||||
*/
|
||||
public void setContentDispositionFormData(String name, String filename, Charset charset) {
|
||||
public void setContentDispositionFormData(String name, @Nullable String filename, @Nullable Charset charset) {
|
||||
Assert.notNull(name, "'name' must not be null");
|
||||
ContentDisposition disposition = ContentDisposition.builder("form-data")
|
||||
.name(name).filename(filename, charset).build();
|
||||
@@ -811,6 +812,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* to get multiple content languages.</p>
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public Locale getContentLanguage() {
|
||||
return getValuesAsList(CONTENT_LANGUAGE)
|
||||
.stream()
|
||||
@@ -852,6 +854,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* by the {@code Content-Type} header.
|
||||
* <p>Returns {@code null} when the content-type is unknown.
|
||||
*/
|
||||
@Nullable
|
||||
public MediaType getContentType() {
|
||||
String value = getFirst(CONTENT_TYPE);
|
||||
return (StringUtils.hasLength(value) ? MediaType.parseMediaType(value) : null);
|
||||
@@ -936,6 +939,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
* {@linkplain InetSocketAddress#getPort() port} will be {@code 0}.
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public InetSocketAddress getHost() {
|
||||
String value = getFirst(HOST);
|
||||
if (value == null) {
|
||||
@@ -1076,6 +1080,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() {
|
||||
String value = getFirst(LOCATION);
|
||||
return (value != null ? URI.create(value) : null);
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.http;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Java 5 enumeration of HTTP request methods. Intended for use
|
||||
* with {@link org.springframework.http.client.ClientHttpRequest}
|
||||
@@ -48,6 +50,7 @@ public enum HttpMethod {
|
||||
* @return the corresponding {@code HttpMethod}, or {@code null} if not found
|
||||
* @since 4.2.4
|
||||
*/
|
||||
@Nullable
|
||||
public static HttpMethod resolve(String method) {
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.http;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an HTTP request message, consisting of
|
||||
* {@linkplain #getMethod() method} and {@linkplain #getURI() uri}.
|
||||
@@ -32,6 +34,7 @@ public interface HttpRequest extends HttpMessage {
|
||||
* @return the HTTP method as an HttpMethod enum value, or {@code null}
|
||||
* if not resolvable (e.g. in case of a non-standard HTTP method)
|
||||
*/
|
||||
@Nullable
|
||||
default HttpMethod getMethod() {
|
||||
return HttpMethod.resolve(getMethodValue());
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
@@ -380,7 +381,7 @@ public class MediaType extends MimeType implements Serializable {
|
||||
* @param parameters the parameters, may be {@code null}
|
||||
* @throws IllegalArgumentException if any of the parameters contain illegal characters
|
||||
*/
|
||||
public MediaType(MediaType other, Map<String, String> parameters) {
|
||||
public MediaType(MediaType other, @Nullable Map<String, String> parameters) {
|
||||
super(other.getType(), other.getSubtype(), parameters);
|
||||
}
|
||||
|
||||
@@ -391,7 +392,7 @@ public class MediaType extends MimeType implements Serializable {
|
||||
* @param parameters the parameters, may be {@code null}
|
||||
* @throws IllegalArgumentException if any of the parameters contain illegal characters
|
||||
*/
|
||||
public MediaType(String type, String subtype, Map<String, String> parameters) {
|
||||
public MediaType(String type, String subtype, @Nullable Map<String, String> parameters) {
|
||||
super(type, subtype, parameters);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -97,7 +98,7 @@ public class MediaTypeFactory {
|
||||
* @param resource the resource to introspect
|
||||
* @return the corresponding media type, or {@code null} if none found
|
||||
*/
|
||||
public static Optional<MediaType> getMediaType(Resource resource) {
|
||||
public static Optional<MediaType> getMediaType(@Nullable Resource resource) {
|
||||
return Optional.ofNullable(resource)
|
||||
.map(Resource::getFilename)
|
||||
.flatMap(MediaTypeFactory::getMediaType);
|
||||
@@ -108,7 +109,7 @@ public class MediaTypeFactory {
|
||||
* @param filename the file name plus extension
|
||||
* @return the corresponding media type, or {@code null} if none found
|
||||
*/
|
||||
public static Optional<MediaType> getMediaType(String filename) {
|
||||
public static Optional<MediaType> getMediaType(@Nullable String filename) {
|
||||
return getMediaTypes(filename).stream().findFirst();
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ public class MediaTypeFactory {
|
||||
* @param filename the file name plus extension
|
||||
* @return the corresponding media types, or an empty list if none found
|
||||
*/
|
||||
public static List<MediaType> getMediaTypes(String filename) {
|
||||
public static List<MediaType> getMediaTypes(@Nullable String filename) {
|
||||
return Optional.ofNullable(StringUtils.getFilenameExtension(filename))
|
||||
.map(s -> s.toLowerCase(Locale.ENGLISH))
|
||||
.map(fileExtensionToMediaTypes::get)
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -159,6 +160,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() {
|
||||
if (this.type == null) {
|
||||
T body = getBody();
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.http;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -73,6 +74,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
/**
|
||||
* Return the cookie "Domain" attribute, or {@code null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
@@ -80,6 +82,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
/**
|
||||
* Return the cookie "Path" attribute, or {@code null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.apache.http.protocol.HttpContext;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -204,6 +205,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* @since 4.2
|
||||
* @see #mergeRequestConfig(RequestConfig)
|
||||
*/
|
||||
@Nullable
|
||||
protected RequestConfig createRequestConfig(Object client) {
|
||||
if (client instanceof Configurable) {
|
||||
RequestConfig clientRequestConfig = ((Configurable) client).getConfig();
|
||||
@@ -220,7 +222,8 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* (may be {@code null} if the given client config is {@code null})
|
||||
* @since 4.2
|
||||
*/
|
||||
protected RequestConfig mergeRequestConfig(RequestConfig clientConfig) {
|
||||
@Nullable
|
||||
protected RequestConfig mergeRequestConfig(@Nullable RequestConfig clientConfig) {
|
||||
if (this.requestConfig == null) { // nothing to merge
|
||||
return clientConfig;
|
||||
}
|
||||
@@ -286,6 +289,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||
* @param uri the URI
|
||||
* @return the http context
|
||||
*/
|
||||
@Nullable
|
||||
protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link ClientHttpRequestFactory} wrapper with support for {@link ClientHttpRequestInterceptor}s.
|
||||
@@ -41,7 +42,7 @@ public class InterceptingClientHttpRequestFactory extends AbstractClientHttpRequ
|
||||
* @param interceptors the interceptors that are to be applied (can be {@code null})
|
||||
*/
|
||||
public InterceptingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory,
|
||||
List<ClientHttpRequestInterceptor> interceptors) {
|
||||
@Nullable List<ClientHttpRequestInterceptor> interceptors) {
|
||||
|
||||
super(requestFactory);
|
||||
this.interceptors = (interceptors != null ? interceptors : Collections.emptyList());
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.net.URLConnection;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -180,7 +181,7 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
|
||||
* @return the opened connection
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
protected HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException {
|
||||
protected HttpURLConnection openConnection(URL url, @Nullable Proxy proxy) throws IOException {
|
||||
URLConnection urlConnection = (proxy != null ? url.openConnection(proxy) : url.openConnection());
|
||||
if (!HttpURLConnection.class.isInstance(urlConnection)) {
|
||||
throw new IllegalStateException("HttpURLConnection required for [" + url + "] but got: " + urlConnection);
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
* contains the {@code ClientHttpRequest} and {@code ClientHttpResponse},
|
||||
* as well as a basic implementation of these interfaces.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.client;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -27,6 +27,7 @@ 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;
|
||||
@@ -111,7 +112,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
|
||||
* @param writeAction the action to write the request body (may be {@code null})
|
||||
* @return a completion publisher
|
||||
*/
|
||||
protected Mono<Void> doCommit(Supplier<? extends Mono<Void>> writeAction) {
|
||||
protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) {
|
||||
if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
* {@link org.springframework.http.client.reactive.ClientHttpResponse} as well as a
|
||||
* {@link org.springframework.http.client.reactive.ClientHttpConnector}.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.client.reactive;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* This package provides generic HTTP support classes,
|
||||
* to be used by higher-level classes like RestTemplate.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.client.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -28,6 +28,7 @@ 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
|
||||
@@ -53,7 +54,7 @@ public interface HttpMessageReader<T> {
|
||||
* @param mediaType the media type for the read, possibly {@code null}
|
||||
* @return {@code true} if readable, {@code false} otherwise
|
||||
*/
|
||||
boolean canRead(ResolvableType elementType, MediaType mediaType);
|
||||
boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Read from the input message and encode to a stream of objects.
|
||||
|
||||
@@ -28,6 +28,7 @@ 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
|
||||
@@ -67,7 +68,7 @@ public interface HttpMessageWriter<T> {
|
||||
* @return indicates completion or error
|
||||
*/
|
||||
Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType elementType,
|
||||
MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints);
|
||||
@Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints);
|
||||
|
||||
/**
|
||||
* Server-side only alternative to
|
||||
@@ -85,7 +86,7 @@ public interface HttpMessageWriter<T> {
|
||||
* @return a {@link Mono} that indicates completion of writing or error
|
||||
*/
|
||||
default Mono<Void> write(Publisher<? extends T> inputStream, ResolvableType actualType,
|
||||
ResolvableType elementType, MediaType mediaType, ServerHttpRequest request,
|
||||
ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request,
|
||||
ServerHttpResponse response, Map<String, Object> hints) {
|
||||
|
||||
return write(inputStream, elementType, mediaType, response, hints);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.http.codec;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.http.codec.json.Jackson2JsonEncoder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Representation for a Server-Sent Event for use with Spring's reactive Web support.
|
||||
@@ -58,6 +59,7 @@ public class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the {@code id} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String id() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ public class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the {@code event} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String event() {
|
||||
return this.event;
|
||||
}
|
||||
@@ -72,6 +75,7 @@ public class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the {@code data} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public T data() {
|
||||
return this.data;
|
||||
}
|
||||
@@ -79,6 +83,7 @@ public class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the {@code retry} field of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public Duration retry() {
|
||||
return this.retry;
|
||||
}
|
||||
@@ -86,6 +91,7 @@ public class ServerSentEvent<T> {
|
||||
/**
|
||||
* Return the comment of this event, if available.
|
||||
*/
|
||||
@Nullable
|
||||
public String comment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ 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;
|
||||
|
||||
/**
|
||||
* {@code HttpMessageWriter} for {@code "text/event-stream"} responses.
|
||||
@@ -74,6 +75,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
||||
/**
|
||||
* Return the configured {@code Encoder}, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Encoder<?> getEncoder() {
|
||||
return this.encoder;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* JSON encoder and decoder support.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.codec.json;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Multipart support.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.codec.multipart;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
@@ -7,4 +7,7 @@
|
||||
* {@link org.springframework.http.codec.HttpMessageWriter} for reading and
|
||||
* writing the body of HTTP requests and responses.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.codec;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* XML encoder and decoder support.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.codec.xml;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract base class for most {@link GenericHttpMessageConverter} implementations.
|
||||
@@ -123,7 +124,7 @@ public abstract class AbstractGenericHttpMessageConverter<T> extends AbstractHtt
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws HttpMessageNotWritableException in case of conversion errors
|
||||
*/
|
||||
protected abstract void writeInternal(T t, Type type, HttpOutputMessage outputMessage)
|
||||
protected abstract void writeInternal(T t, @Nullable Type type, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -117,6 +118,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
* Return the default character set, if any.
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Charset getDefaultCharset() {
|
||||
return this.defaultCharset;
|
||||
}
|
||||
@@ -141,7 +143,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
* @return {@code true} if the supported media types include the media type,
|
||||
* or if the media type is {@code null}
|
||||
*/
|
||||
protected boolean canRead(MediaType mediaType) {
|
||||
protected boolean canRead(@Nullable MediaType mediaType) {
|
||||
if (mediaType == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -172,7 +174,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
* @return {@code true} if the supported media types are compatible with the media type,
|
||||
* or if the media type is {@code null}
|
||||
*/
|
||||
protected boolean canWrite(MediaType mediaType) {
|
||||
protected boolean canWrite(@Nullable MediaType mediaType) {
|
||||
if (mediaType == null || MediaType.ALL.equals(mediaType)) {
|
||||
return true;
|
||||
}
|
||||
@@ -273,6 +275,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
* @param t the type to return the content type for
|
||||
* @return the content type, or {@code null} if not known
|
||||
*/
|
||||
@Nullable
|
||||
protected MediaType getDefaultContentType(T t) throws IOException {
|
||||
List<MediaType> mediaTypes = getSupportedMediaTypes();
|
||||
return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null);
|
||||
@@ -285,7 +288,8 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
|
||||
* @param t the type to return the content length for
|
||||
* @return the content length, or {@code null} if not known
|
||||
*/
|
||||
protected Long getContentLength(T t, MediaType contentType) throws IOException {
|
||||
@Nullable
|
||||
protected Long getContentLength(T t, @Nullable MediaType contentType) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.StreamingHttpOutputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
@@ -431,6 +433,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
* @param part the part to determine the file name for
|
||||
* @return the filename, or {@code null} if not known
|
||||
*/
|
||||
@Nullable
|
||||
protected String getFilename(Object part) {
|
||||
if (part instanceof Resource) {
|
||||
Resource resource = (Resource) part;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.lang.reflect.Type;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A specialization of {@link HttpMessageConverter} that can convert an HTTP request
|
||||
@@ -48,7 +49,7 @@ public interface GenericHttpMessageConverter<T> extends HttpMessageConverter<T>
|
||||
* Typically the value of a {@code Content-Type} header.
|
||||
* @return {@code true} if readable; {@code false} otherwise
|
||||
*/
|
||||
boolean canRead(Type type, Class<?> contextClass, MediaType mediaType);
|
||||
boolean canRead(Type type, @Nullable Class<?> contextClass, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Read an object of the given type form the given input message, and returns it.
|
||||
@@ -62,7 +63,7 @@ public interface GenericHttpMessageConverter<T> extends HttpMessageConverter<T>
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws HttpMessageNotReadableException in case of conversion errors
|
||||
*/
|
||||
T read(Type type, Class<?> contextClass, HttpInputMessage inputMessage)
|
||||
T read(Type type, @Nullable Class<?> contextClass, HttpInputMessage inputMessage)
|
||||
throws IOException, HttpMessageNotReadableException;
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ public interface GenericHttpMessageConverter<T> extends HttpMessageConverter<T>
|
||||
* @return {@code true} if writable; {@code false} otherwise
|
||||
* @since 4.2
|
||||
*/
|
||||
boolean canWrite(Type type, Class<?> clazz, MediaType mediaType);
|
||||
boolean canWrite(@Nullable Type type, Class<?> clazz, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Write an given object to the given output message.
|
||||
@@ -98,7 +99,7 @@ public interface GenericHttpMessageConverter<T> extends HttpMessageConverter<T>
|
||||
* @throws HttpMessageNotWritableException in case of conversion errors
|
||||
* @since 4.2
|
||||
*/
|
||||
void write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
|
||||
void write(T t, @Nullable Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.http.converter;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Thrown by {@link HttpMessageConverter} implementations when a conversion attempt fails.
|
||||
@@ -41,7 +42,7 @@ public class HttpMessageConversionException extends NestedRuntimeException {
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause (if any)
|
||||
*/
|
||||
public HttpMessageConversionException(String msg, Throwable cause) {
|
||||
public HttpMessageConversionException(String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface that specifies a converter that can convert from and to HTTP requests and responses.
|
||||
@@ -39,7 +40,7 @@ public interface HttpMessageConverter<T> {
|
||||
* typically the value of a {@code Content-Type} header.
|
||||
* @return {@code true} if readable; {@code false} otherwise
|
||||
*/
|
||||
boolean canRead(Class<?> clazz, MediaType mediaType);
|
||||
boolean canRead(Class<?> clazz, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Indicates whether the given class can be written by this converter.
|
||||
@@ -48,7 +49,7 @@ public interface HttpMessageConverter<T> {
|
||||
* typically the value of an {@code Accept} header.
|
||||
* @return {@code true} if writable; {@code false} otherwise
|
||||
*/
|
||||
boolean canWrite(Class<?> clazz, MediaType mediaType);
|
||||
boolean canWrite(Class<?> clazz, @Nullable MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Return the list of {@link MediaType} objects supported by this converter.
|
||||
@@ -80,7 +81,7 @@ public interface HttpMessageConverter<T> {
|
||||
* @throws IOException in case of I/O errors
|
||||
* @throws HttpMessageNotWritableException in case of conversion errors
|
||||
*/
|
||||
void write(T t, MediaType contentType, HttpOutputMessage outputMessage)
|
||||
void write(T t, @Nullable MediaType contentType, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.http.converter;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Thrown by {@link HttpMessageConverter} implementations when the
|
||||
* {@link HttpMessageConverter#read} method fails.
|
||||
@@ -39,7 +41,7 @@ public class HttpMessageNotReadableException extends HttpMessageConversionExcept
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause (if any)
|
||||
*/
|
||||
public HttpMessageNotReadableException(String msg, Throwable cause) {
|
||||
public HttpMessageNotReadableException(String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.http.converter;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Thrown by {@link HttpMessageConverter} implementations when the
|
||||
* {@link HttpMessageConverter#write} method fails.
|
||||
@@ -39,7 +41,7 @@ public class HttpMessageNotWritableException extends HttpMessageConversionExcept
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause (if any)
|
||||
*/
|
||||
public HttpMessageNotWritableException(String msg, Throwable cause) {
|
||||
public HttpMessageNotWritableException(String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides an HttpMessageConverter for the CBOR data format.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.cbor;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Provides HttpMessageConverter implementations for handling Atom and RSS feeds.
|
||||
* Based on the <a href="https://github.com/rometools/rome">ROME tools</a> project.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.feed;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.http.converter.HttpMessageConversionException;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.TypeUtils;
|
||||
|
||||
@@ -315,7 +316,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
||||
* in which the target type appears in a method signature (can be {@code null})
|
||||
* @return the Jackson JavaType
|
||||
*/
|
||||
protected JavaType getJavaType(Type type, Class<?> contextClass) {
|
||||
protected JavaType getJavaType(Type type, @Nullable Class<?> contextClass) {
|
||||
TypeFactory typeFactory = this.objectMapper.getTypeFactory();
|
||||
return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass));
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.AbstractGenericHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Common base class for plain JSON converters, e.g. Gson and JSON-B.
|
||||
@@ -142,7 +143,7 @@ public abstract class AbstractJsonHttpMessageConverter extends AbstractGenericHt
|
||||
* @param writer the {@code} Writer to use
|
||||
* @throws Exception in case of write failures
|
||||
*/
|
||||
protected abstract void writeInternal(Object o, Type type, Writer writer) throws Exception;
|
||||
protected abstract void writeInternal(Object o, @Nullable Type type, Writer writer) throws Exception;
|
||||
|
||||
|
||||
private static Reader getReader(HttpInputMessage inputMessage) throws IOException {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides HttpMessageConverter implementations for handling JSON.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.json;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides an HttpMessageConverter abstraction to convert between Java objects and HTTP input/output messages.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Provides an HttpMessageConverter implementation for handling
|
||||
* <a href="https://developers.google.com/protocol-buffers/">Google Protocol Buffers</a>.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.protobuf;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides an HttpMessageConverter for the Smile data format ("binary JSON").
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.smile;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides a comprehensive HttpMessageConverter variant for form handling.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides HttpMessageConverter implementations for handling XML.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.converter.xml;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Contains a basic abstraction over client/server-side HTTP. This package contains
|
||||
* the {@code HttpInputMessage} and {@code HttpOutputMessage} interfaces.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
* contains the {@code ServerHttpRequest} and {@code ServerHttpResponse},
|
||||
* as well as a Servlet-based implementation of these interfaces.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.server;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.publisher.Operators;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -108,6 +109,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
* Reads a data from the input, if possible.
|
||||
* @return the data that was read; or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract T read() throws IOException;
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -186,7 +187,7 @@ public abstract class AbstractServerHttpResponse implements ServerHttpResponse {
|
||||
* @param writeAction the action to write the response body (may be {@code null})
|
||||
* @return a completion publisher
|
||||
*/
|
||||
protected Mono<Void> doCommit(Supplier<? extends Mono<Void>> writeAction) {
|
||||
protected Mono<Void> doCommit(@Nullable Supplier<? extends Mono<Void>> writeAction) {
|
||||
if (!this.state.compareAndSet(State.NEW, State.COMMITTING)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Skipping doCommit (response already committed).");
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -57,6 +58,7 @@ public interface ServerHttpRequest extends HttpRequest, ReactiveHttpInputMessage
|
||||
/**
|
||||
* Return the remote address where this request is connected to, if available.
|
||||
*/
|
||||
@Nullable
|
||||
InetSocketAddress getRemoteAddress();
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.function.Function;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ReactiveHttpOutputMessage;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
|
||||
/**
|
||||
* Return the HTTP status code or {@code null} if not set.
|
||||
*/
|
||||
@Nullable
|
||||
HttpStatus getStatusCode();
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.reactivestreams.Subscription;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -133,6 +134,7 @@ public class ServletHttpHandlerAdapter implements Servlet {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServletConfig getServletConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -189,6 +190,7 @@ public class ServletServerHttpRequest extends AbstractServerHttpRequest {
|
||||
* Read from the request body InputStream and return a DataBuffer.
|
||||
* Invoked only when {@link ServletInputStream#isReady()} returns "true".
|
||||
*/
|
||||
@Nullable
|
||||
protected DataBuffer readFromInputStream() throws IOException {
|
||||
int read = this.request.getInputStream().read(this.buffer);
|
||||
if (logger.isTraceEnabled()) {
|
||||
|
||||
@@ -7,4 +7,7 @@
|
||||
* <p>Also provides implementations adapting to different runtimes
|
||||
* including Servlet 3.1 containers, Netty + Reactor IO, and Undertow.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.http.server.reactive;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -7,4 +7,7 @@
|
||||
* For information on Hessian, see the
|
||||
* <a href="http://www.caucho.com/hessian">Hessian website</a>
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.remoting.caucho;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream;
|
||||
import org.springframework.remoting.support.RemoteInvocation;
|
||||
import org.springframework.remoting.support.RemoteInvocationResult;
|
||||
@@ -267,7 +268,7 @@ public abstract class AbstractHttpInvokerRequestExecutor implements HttpInvokerR
|
||||
* @throws IOException if creation of the ObjectInputStream failed
|
||||
* @see org.springframework.remoting.rmi.CodebaseAwareObjectInputStream
|
||||
*/
|
||||
protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException {
|
||||
protected ObjectInputStream createObjectInputStream(InputStream is, @Nullable String codebaseUrl) throws IOException {
|
||||
return new CodebaseAwareObjectInputStream(is, getBeanClassLoader(), codebaseUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContext;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.remoting.support.RemoteInvocationResult;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -238,6 +239,7 @@ public class HttpComponentsHttpInvokerRequestExecutor extends AbstractHttpInvoke
|
||||
* target service
|
||||
* @return the RequestConfig to use
|
||||
*/
|
||||
@Nullable
|
||||
protected RequestConfig createRequestConfig(HttpInvokerClientConfiguration config) {
|
||||
HttpClient client = getHttpClient();
|
||||
if (client instanceof Configurable) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.remoting.httpinvoker;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Configuration interface for executing HTTP invoker requests.
|
||||
*
|
||||
@@ -37,6 +39,7 @@ public interface HttpInvokerClientConfiguration {
|
||||
* @return the codebase URL, or {@code null} if none
|
||||
* @see java.rmi.server.RMIClassLoader
|
||||
*/
|
||||
@Nullable
|
||||
String getCodebaseUrl();
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.remoting.RemoteAccessException;
|
||||
import org.springframework.remoting.RemoteConnectFailureException;
|
||||
import org.springframework.remoting.RemoteInvocationFailureException;
|
||||
@@ -209,6 +210,7 @@ public class HttpInvokerClientInterceptor extends RemoteInvocationBasedAccessor
|
||||
* @return the RemoteAccessException to throw, or {@code null} to have the
|
||||
* original exception propagated to the caller
|
||||
*/
|
||||
@Nullable
|
||||
protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) {
|
||||
if (ex instanceof ConnectException) {
|
||||
return new RemoteConnectFailureException(
|
||||
|
||||
@@ -8,4 +8,7 @@
|
||||
* being tied to Java. Nevertheless, it is as easy to set up as Hessian,
|
||||
* which is its main advantage compared to RMI.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.remoting.httpinvoker;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.remoting.RemoteAccessException;
|
||||
import org.springframework.remoting.RemoteConnectFailureException;
|
||||
import org.springframework.remoting.RemoteLookupFailureException;
|
||||
@@ -112,6 +113,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
|
||||
/**
|
||||
* Return a reference to an existing JAX-WS Service instance, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Service getJaxWsService() {
|
||||
return this.jaxWsService;
|
||||
}
|
||||
@@ -491,6 +493,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
|
||||
* @see #getPortStub()
|
||||
* @see #doInvoke(org.aopalliance.intercept.MethodInvocation, Object)
|
||||
*/
|
||||
@Nullable
|
||||
protected Object doInvoke(MethodInvocation invocation) throws Throwable {
|
||||
try {
|
||||
return doInvoke(invocation, getPortStub());
|
||||
@@ -516,6 +519,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
|
||||
* @throws Throwable in case of invocation failure
|
||||
* @see #getPortStub()
|
||||
*/
|
||||
@Nullable
|
||||
protected Object doInvoke(MethodInvocation invocation, Object portStub) throws Throwable {
|
||||
Method method = invocation.getMethod();
|
||||
try {
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
* as included in Java 6 and Java EE 5. This package provides proxy
|
||||
* factories for accessing JAX-WS services and ports.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.remoting.jaxws;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -21,9 +21,11 @@ import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -63,7 +65,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
|
||||
* @param method the unsupported HTTP request method
|
||||
* @param supportedMethods the actually supported HTTP methods (may be {@code null})
|
||||
*/
|
||||
public HttpRequestMethodNotSupportedException(String method, Collection<String> supportedMethods) {
|
||||
public HttpRequestMethodNotSupportedException(String method, @Nullable Collection<String> supportedMethods) {
|
||||
this(method, StringUtils.toStringArray(supportedMethods));
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
|
||||
* @param method the unsupported HTTP request method
|
||||
* @param supportedMethods the actually supported HTTP methods (may be {@code null})
|
||||
*/
|
||||
public HttpRequestMethodNotSupportedException(String method, String[] supportedMethods) {
|
||||
public HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods) {
|
||||
this(method, supportedMethods, "Request method '" + method + "' not supported");
|
||||
}
|
||||
|
||||
@@ -99,6 +101,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
|
||||
/**
|
||||
* Return the actually supported HTTP methods, or {@code null} if not known.
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getSupportedMethods() {
|
||||
return this.supportedMethods;
|
||||
}
|
||||
@@ -108,6 +111,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException {
|
||||
* or {@code null} if not known.
|
||||
* @since 3.2
|
||||
*/
|
||||
@Nullable
|
||||
public Set<HttpMethod> getSupportedHttpMethods() {
|
||||
if (this.supportedMethods == null) {
|
||||
return null;
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when an HTTP request handler requires a pre-existing session.
|
||||
*
|
||||
@@ -54,6 +56,7 @@ public class HttpSessionRequiredException extends ServletException {
|
||||
* Return the name of the expected session attribute, if any.
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public String getExpectedAttribute() {
|
||||
return this.expectedAttribute;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
@@ -89,6 +90,7 @@ public abstract class AbstractMappingContentNegotiationStrategy extends MappingM
|
||||
* Extract a key from the request to use to look up media types.
|
||||
* @return the lookup key or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract String getMediaTypeKey(NativeWebRequest request);
|
||||
|
||||
/**
|
||||
@@ -104,6 +106,7 @@ public abstract class AbstractMappingContentNegotiationStrategy extends MappingM
|
||||
* determine the media type(s). If a MediaType is returned from
|
||||
* this method it will be added to the cache in the base class.
|
||||
*/
|
||||
@Nullable
|
||||
protected MediaType handleNoMatch(NativeWebRequest request, String key)
|
||||
throws HttpMediaTypeNotAcceptableException {
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
@@ -99,6 +100,7 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
|
||||
* @since 4.3
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends ContentNegotiationStrategy> T getStrategy(Class<T> strategyType) {
|
||||
for (ContentNegotiationStrategy strategy : getStrategies()) {
|
||||
if (strategyType.isInstance(strategy)) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -102,6 +103,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten
|
||||
* Use this method for a reverse lookup from extension to MediaType.
|
||||
* @return a MediaType for the key, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected MediaType lookupMediaType(String extension) {
|
||||
return this.mediaTypes.get(extension.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.accept;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -27,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
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;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
@@ -146,6 +148,7 @@ public class PathExtensionContentNegotiationStrategy extends AbstractMappingCont
|
||||
* @return the MediaType for the extension, or {@code null} if none found
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public MediaType getMediaTypeForResource(Resource resource) {
|
||||
Assert.notNull(resource, "Resource must not be null");
|
||||
MediaType mediaType = null;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.accept;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -12,4 +12,7 @@
|
||||
* <p>{@link org.springframework.web.accept.ContentNegotiationManager} is used to delegate to one
|
||||
* ore more of the above strategies in a specific order.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.accept;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.bind;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
@@ -64,7 +65,7 @@ public class ServletRequestDataBinder extends WebDataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public ServletRequestDataBinder(Object target) {
|
||||
public ServletRequestDataBinder(@Nullable Object target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ public class ServletRequestDataBinder extends WebDataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @param objectName the name of the target object
|
||||
*/
|
||||
public ServletRequestDataBinder(Object target, String objectName) {
|
||||
public ServletRequestDataBinder(@Nullable Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.web.bind;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Parameter extraction methods, for an approach distinct from data binding,
|
||||
* in which parameters of specific types are required.
|
||||
@@ -53,6 +55,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer getIntParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
@@ -131,6 +134,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static Long getLongParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
@@ -209,6 +213,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static Float getFloatParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
@@ -287,6 +292,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static Double getDoubleParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
@@ -367,6 +373,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static Boolean getBooleanParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
@@ -454,6 +461,7 @@ public abstract class ServletRequestUtils {
|
||||
* @throws ServletRequestBindingException a subclass of ServletException,
|
||||
* so it doesn't need to be caught
|
||||
*/
|
||||
@Nullable
|
||||
public static String getStringParameter(ServletRequest request, String name)
|
||||
throws ServletRequestBindingException {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.validation.DataBinder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -87,7 +88,7 @@ public class WebDataBinder extends DataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public WebDataBinder(Object target) {
|
||||
public WebDataBinder(@Nullable Object target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ public class WebDataBinder extends DataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @param objectName the name of the target object
|
||||
*/
|
||||
public WebDataBinder(Object target, String objectName) {
|
||||
public WebDataBinder(@Nullable Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
|
||||
@@ -258,7 +259,8 @@ public class WebDataBinder extends DataBinder {
|
||||
* @param fieldType the type of the field
|
||||
* @return the empty value (for most fields: null)
|
||||
*/
|
||||
protected Object getEmptyValue(String field, Class<?> fieldType) {
|
||||
@Nullable
|
||||
protected Object getEmptyValue(String field, @Nullable Class<?> fieldType) {
|
||||
if (fieldType != null) {
|
||||
try {
|
||||
if (boolean.class == fieldType || Boolean.class == fieldType) {
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Annotations for binding requests to controllers and handler methods
|
||||
* as well as for binding request parameters to method arguments.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.bind.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides web-specific data binding functionality.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.bind;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.validation.BindingErrorProcessor;
|
||||
import org.springframework.validation.MessageCodesResolver;
|
||||
import org.springframework.validation.Validator;
|
||||
@@ -107,6 +108,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
/**
|
||||
* Return the strategy to use for resolving errors into message codes.
|
||||
*/
|
||||
@Nullable
|
||||
public final MessageCodesResolver getMessageCodesResolver() {
|
||||
return this.messageCodesResolver;
|
||||
}
|
||||
@@ -125,6 +127,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
/**
|
||||
* Return the strategy to use for processing binding errors.
|
||||
*/
|
||||
@Nullable
|
||||
public final BindingErrorProcessor getBindingErrorProcessor() {
|
||||
return this.bindingErrorProcessor;
|
||||
}
|
||||
@@ -139,6 +142,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
/**
|
||||
* Return the Validator to apply after each binding step, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public final Validator getValidator() {
|
||||
return this.validator;
|
||||
}
|
||||
@@ -154,6 +158,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
/**
|
||||
* Return the ConversionService which will apply to every DataBinder.
|
||||
*/
|
||||
@Nullable
|
||||
public final ConversionService getConversionService() {
|
||||
return this.conversionService;
|
||||
}
|
||||
@@ -175,6 +180,7 @@ public class ConfigurableWebBindingInitializer implements WebBindingInitializer
|
||||
/**
|
||||
* Return the PropertyEditorRegistrars to be applied to every DataBinder.
|
||||
*/
|
||||
@Nullable
|
||||
public final PropertyEditorRegistrar[] getPropertyEditorRegistrars() {
|
||||
return this.propertyEditorRegistrars;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class DefaultDataBinderFactory implements WebDataBinderFactory {
|
||||
* @param initializer for global data binder initialization
|
||||
* (or {@code null} if none)
|
||||
*/
|
||||
public DefaultDataBinderFactory(WebBindingInitializer initializer) {
|
||||
public DefaultDataBinderFactory(@Nullable WebBindingInitializer initializer) {
|
||||
this.initializer = initializer;
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ public class DefaultDataBinderFactory implements WebDataBinderFactory {
|
||||
* @param webRequest the current request
|
||||
* @throws Exception in case of invalid state or arguments
|
||||
*/
|
||||
protected WebDataBinder createBinderInstance(Object target, String objectName,
|
||||
protected WebDataBinder createBinderInstance(@Nullable Object target, String objectName,
|
||||
NativeWebRequest webRequest) throws Exception {
|
||||
|
||||
return new WebRequestDataBinder(target, objectName);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
/**
|
||||
@@ -46,6 +47,7 @@ public interface SessionAttributeStore {
|
||||
* @param attributeName the name of the attribute
|
||||
* @return the current attribute value, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
Object retrieveAttribute(WebRequest request, String attributeName);
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
@@ -35,6 +36,6 @@ public interface WebDataBinderFactory {
|
||||
* @return the created {@link WebDataBinder} instance, never null
|
||||
* @throws Exception raised if the creation and initialization of the data binder fails
|
||||
*/
|
||||
WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName) throws Exception;
|
||||
WebDataBinder createBinder(NativeWebRequest webRequest, @Nullable Object target, String objectName) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.http.codec.multipart.FormFieldPart;
|
||||
import org.springframework.http.codec.multipart.Part;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
@@ -47,7 +48,7 @@ public class WebExchangeDataBinder extends WebDataBinder {
|
||||
* binder is just used to convert a plain parameter value)
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public WebExchangeDataBinder(Object target) {
|
||||
public WebExchangeDataBinder(@Nullable Object target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ public class WebExchangeDataBinder extends WebDataBinder {
|
||||
* binder is just used to convert a plain parameter value)
|
||||
* @param objectName the name of the target object
|
||||
*/
|
||||
public WebExchangeDataBinder(Object target, String objectName) {
|
||||
public WebExchangeDataBinder(@Nullable Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ package org.springframework.web.bind.support;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.Part;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -75,7 +77,7 @@ public class WebRequestDataBinder extends WebDataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @see #DEFAULT_OBJECT_NAME
|
||||
*/
|
||||
public WebRequestDataBinder(Object target) {
|
||||
public WebRequestDataBinder(@Nullable Object target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@@ -85,7 +87,7 @@ public class WebRequestDataBinder extends WebDataBinder {
|
||||
* if the binder is just used to convert a plain parameter value)
|
||||
* @param objectName the name of the target object
|
||||
*/
|
||||
public WebRequestDataBinder(Object target, String objectName) {
|
||||
public WebRequestDataBinder(@Nullable Object target, String objectName) {
|
||||
super(target, objectName);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support classes for web data binding.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.bind.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
@@ -128,7 +129,7 @@ public interface AsyncRestOperations {
|
||||
* @return the value for the {@code Location} header wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
ListenableFuture<URI> postForLocation(String url, HttpEntity<?> request, Object... uriVariables)
|
||||
ListenableFuture<URI> postForLocation(String url, @Nullable HttpEntity<?> request, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -142,7 +143,7 @@ public interface AsyncRestOperations {
|
||||
* @return the value for the {@code Location} header wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
ListenableFuture<URI> postForLocation(String url, HttpEntity<?> request, Map<String, ?> uriVariables)
|
||||
ListenableFuture<URI> postForLocation(String url, @Nullable HttpEntity<?> request, Map<String, ?> uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -154,7 +155,7 @@ public interface AsyncRestOperations {
|
||||
* @return the value for the {@code Location} header wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
ListenableFuture<URI> postForLocation(URI url, HttpEntity<?> request) throws RestClientException;
|
||||
ListenableFuture<URI> postForLocation(URI url, @Nullable HttpEntity<?> request) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Create a new resource by POSTing the given object to the URI template,
|
||||
@@ -166,7 +167,7 @@ public interface AsyncRestOperations {
|
||||
* @return the entity wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, HttpEntity<?> request,
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, @Nullable HttpEntity<?> request,
|
||||
Class<T> responseType, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -179,7 +180,7 @@ public interface AsyncRestOperations {
|
||||
* @return the entity wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, HttpEntity<?> request,
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(String url, @Nullable HttpEntity<?> request,
|
||||
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -190,7 +191,7 @@ public interface AsyncRestOperations {
|
||||
* @return the entity wrapped in a {@link Future}
|
||||
* @see org.springframework.http.HttpEntity
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url, HttpEntity<?> request,
|
||||
<T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url, @Nullable HttpEntity<?> request,
|
||||
Class<T> responseType) throws RestClientException;
|
||||
|
||||
|
||||
@@ -205,7 +206,7 @@ public interface AsyncRestOperations {
|
||||
* @param uriVariables the variables to expand the template
|
||||
* @see HttpEntity
|
||||
*/
|
||||
ListenableFuture<?> put(String url, HttpEntity<?> request, Object... uriVariables)
|
||||
ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -217,7 +218,7 @@ public interface AsyncRestOperations {
|
||||
* @param uriVariables the variables to expand the template
|
||||
* @see HttpEntity
|
||||
*/
|
||||
ListenableFuture<?> put(String url, HttpEntity<?> request, Map<String, ?> uriVariables)
|
||||
ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Map<String, ?> uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -227,7 +228,7 @@ public interface AsyncRestOperations {
|
||||
* @param request the Object to be PUT (may be {@code null})
|
||||
* @see HttpEntity
|
||||
*/
|
||||
ListenableFuture<?> put(URI url, HttpEntity<?> request) throws RestClientException;
|
||||
ListenableFuture<?> put(URI url, @Nullable HttpEntity<?> request) throws RestClientException;
|
||||
|
||||
|
||||
// DELETE
|
||||
@@ -305,7 +306,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables)
|
||||
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -322,7 +323,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
@Nullable HttpEntity<?> requestEntity, Class<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -337,7 +338,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, Class<T> responseType)
|
||||
@Nullable HttpEntity<?> requestEntity, Class<T> responseType)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -358,7 +359,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
|
||||
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
|
||||
Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -379,7 +380,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
|
||||
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
|
||||
Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -399,7 +400,7 @@ public interface AsyncRestOperations {
|
||||
* @return the response as entity wrapped in a {@link Future}
|
||||
*/
|
||||
<T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method,
|
||||
HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
|
||||
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
|
||||
throws RestClientException;
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureAdapter;
|
||||
@@ -498,8 +499,8 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
|
||||
* be {@code null})
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
*/
|
||||
protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method, AsyncRequestCallback requestCallback,
|
||||
ResponseExtractor<T> responseExtractor) throws RestClientException {
|
||||
protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method, @Nullable AsyncRequestCallback requestCallback,
|
||||
@Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
|
||||
|
||||
Assert.notNull(url, "'url' must not be null");
|
||||
Assert.notNull(method, "'method' must not be null");
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
@@ -110,6 +111,7 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
|
||||
* @return the associated charset, or {@code null} if none
|
||||
* @since 4.3.8
|
||||
*/
|
||||
@Nullable
|
||||
protected Charset getCharset(ClientHttpResponse response) {
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
MediaType contentType = headers.getContentType();
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when an HTTP 4xx is received.
|
||||
@@ -61,7 +62,7 @@ public class HttpClientErrorException extends HttpStatusCodeException {
|
||||
* @param responseCharset the response body charset (may be {@code null})
|
||||
*/
|
||||
public HttpClientErrorException(HttpStatus statusCode, String statusText,
|
||||
byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(statusCode, statusText, responseBody, responseCharset);
|
||||
}
|
||||
@@ -77,7 +78,7 @@ public class HttpClientErrorException extends HttpStatusCodeException {
|
||||
* @since 3.1.2
|
||||
*/
|
||||
public HttpClientErrorException(HttpStatus statusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when an HTTP 5xx is received.
|
||||
@@ -62,7 +63,7 @@ public class HttpServerErrorException extends HttpStatusCodeException {
|
||||
* @since 3.0.5
|
||||
*/
|
||||
public HttpServerErrorException(HttpStatus statusCode, String statusText,
|
||||
byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(statusCode, statusText, responseBody, responseCharset);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class HttpServerErrorException extends HttpStatusCodeException {
|
||||
* @since 3.1.2
|
||||
*/
|
||||
public HttpServerErrorException(HttpStatus statusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract base class for exceptions based on an {@link HttpStatus}.
|
||||
@@ -63,7 +64,7 @@ public abstract class HttpStatusCodeException extends RestClientResponseExceptio
|
||||
* @since 3.0.5
|
||||
*/
|
||||
protected HttpStatusCodeException(HttpStatus statusCode, String statusText,
|
||||
byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
this(statusCode, statusText, null, responseBody, responseCharset);
|
||||
}
|
||||
@@ -79,7 +80,7 @@ public abstract class HttpStatusCodeException extends RestClientResponseExceptio
|
||||
* @since 3.1.2
|
||||
*/
|
||||
protected HttpStatusCodeException(HttpStatus statusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(statusCode.value() + " " + statusText, statusCode.value(), statusText,
|
||||
responseHeaders, responseBody, responseCharset);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.client;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Generic callback interface used by {@link RestTemplate}'s retrieval methods
|
||||
@@ -41,6 +42,7 @@ public interface ResponseExtractor<T> {
|
||||
* @return the extracted data
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
@Nullable
|
||||
T extractData(ClientHttpResponse response) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Common base class for exceptions that contain actual HTTP response data.
|
||||
@@ -54,7 +55,7 @@ public class RestClientResponseException extends RestClientException {
|
||||
* @param responseCharset the response body charset (may be {@code null})
|
||||
*/
|
||||
public RestClientResponseException(String message, int statusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset) {
|
||||
|
||||
super(message);
|
||||
this.rawStatusCode = statusCode;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface specifying a basic set of RESTful operations.
|
||||
@@ -51,6 +52,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the variables to expand the template
|
||||
* @return the converted object
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getForObject(String url, Class<T> responseType, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -62,6 +64,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the map containing variables for the URI template
|
||||
* @return the converted object
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -71,6 +74,7 @@ public interface RestOperations {
|
||||
* @param responseType the type of the return value
|
||||
* @return the converted object
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getForObject(URI url, Class<T> responseType) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -150,7 +154,7 @@ public interface RestOperations {
|
||||
* @return the value for the {@code Location} header
|
||||
* @see HttpEntity
|
||||
*/
|
||||
URI postForLocation(String url, Object request, Object... uriVariables) throws RestClientException;
|
||||
URI postForLocation(String url, @Nullable Object request, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Create a new resource by POSTing the given object to the URI template, and returns the value of
|
||||
@@ -164,7 +168,7 @@ public interface RestOperations {
|
||||
* @return the value for the {@code Location} header
|
||||
* @see HttpEntity
|
||||
*/
|
||||
URI postForLocation(String url, Object request, Map<String, ?> uriVariables) throws RestClientException;
|
||||
URI postForLocation(String url, @Nullable Object request, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Create a new resource by POSTing the given object to the URL, and returns the value of the
|
||||
@@ -176,7 +180,7 @@ public interface RestOperations {
|
||||
* @return the value for the {@code Location} header
|
||||
* @see HttpEntity
|
||||
*/
|
||||
URI postForLocation(URI url, Object request) throws RestClientException;
|
||||
URI postForLocation(URI url, @Nullable Object request) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Create a new resource by POSTing the given object to the URI template,
|
||||
@@ -191,7 +195,8 @@ public interface RestOperations {
|
||||
* @return the converted object
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables)
|
||||
@Nullable
|
||||
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -207,7 +212,8 @@ public interface RestOperations {
|
||||
* @return the converted object
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> T postForObject(String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
@Nullable
|
||||
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -221,7 +227,8 @@ public interface RestOperations {
|
||||
* @return the converted object
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> T postForObject(URI url, Object request, Class<T> responseType) throws RestClientException;
|
||||
@Nullable
|
||||
<T> T postForObject(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Create a new resource by POSTing the given object to the URI template,
|
||||
@@ -236,7 +243,7 @@ public interface RestOperations {
|
||||
* @since 3.0.2
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType, Object... uriVariables)
|
||||
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -252,7 +259,7 @@ public interface RestOperations {
|
||||
* @since 3.0.2
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -266,7 +273,7 @@ public interface RestOperations {
|
||||
* @since 3.0.2
|
||||
* @see HttpEntity
|
||||
*/
|
||||
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;
|
||||
<T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException;
|
||||
|
||||
|
||||
// PUT
|
||||
@@ -281,7 +288,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the variables to expand the template
|
||||
* @see HttpEntity
|
||||
*/
|
||||
void put(String url, Object request, Object... uriVariables) throws RestClientException;
|
||||
void put(String url, @Nullable Object request, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Creates a new resource by PUTting the given object to URI template.
|
||||
@@ -293,7 +300,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the variables to expand the template
|
||||
* @see HttpEntity
|
||||
*/
|
||||
void put(String url, Object request, Map<String, ?> uriVariables) throws RestClientException;
|
||||
void put(String url, @Nullable Object request, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
* Creates a new resource by PUTting the given object to URL.
|
||||
@@ -303,7 +310,7 @@ public interface RestOperations {
|
||||
* @param request the Object to be PUT (may be {@code null})
|
||||
* @see HttpEntity
|
||||
*/
|
||||
void put(URI url, Object request) throws RestClientException;
|
||||
void put(URI url, @Nullable Object request) throws RestClientException;
|
||||
|
||||
|
||||
// PATCH
|
||||
@@ -327,7 +334,8 @@ public interface RestOperations {
|
||||
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
|
||||
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
|
||||
*/
|
||||
<T> T patchForObject(String url, Object request, Class<T> responseType, Object... uriVariables)
|
||||
@Nullable
|
||||
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -349,7 +357,8 @@ public interface RestOperations {
|
||||
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
|
||||
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
|
||||
*/
|
||||
<T> T patchForObject(String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
@Nullable
|
||||
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
|
||||
throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -369,7 +378,8 @@ public interface RestOperations {
|
||||
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
|
||||
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
|
||||
*/
|
||||
<T> T patchForObject(URI url, Object request, Class<T> responseType) throws RestClientException;
|
||||
@Nullable
|
||||
<T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException;
|
||||
|
||||
|
||||
|
||||
@@ -442,7 +452,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.0.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
Class<T> responseType, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -458,7 +468,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.0.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -472,7 +482,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.0.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
Class<T> responseType) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -492,7 +502,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(String url,HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -512,7 +522,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -531,7 +541,7 @@ public interface RestOperations {
|
||||
* @return the response as entity
|
||||
* @since 3.2
|
||||
*/
|
||||
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
|
||||
ParameterizedTypeReference<T> responseType) throws RestClientException;
|
||||
|
||||
/**
|
||||
@@ -582,6 +592,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the variables to expand in the template
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
*/
|
||||
@Nullable
|
||||
<T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
|
||||
ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException;
|
||||
|
||||
@@ -596,6 +607,7 @@ public interface RestOperations {
|
||||
* @param uriVariables the variables to expand in the template
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
*/
|
||||
@Nullable
|
||||
<T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
|
||||
ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException;
|
||||
|
||||
@@ -608,6 +620,7 @@ public interface RestOperations {
|
||||
* @param responseExtractor object that extracts the return value from the response
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
*/
|
||||
@Nullable
|
||||
<T> T execute(URI url, HttpMethod method, RequestCallback requestCallback,
|
||||
ResponseExtractor<T> responseExtractor) throws RestClientException;
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
|
||||
import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.SourceHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
@@ -667,8 +668,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
* @param responseExtractor object that extracts the return value from the response (can be {@code null})
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
*/
|
||||
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
|
||||
ResponseExtractor<T> responseExtractor) throws RestClientException {
|
||||
@Nullable
|
||||
protected <T> T doExecute(URI url, HttpMethod method, @Nullable RequestCallback requestCallback,
|
||||
@Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
|
||||
|
||||
Assert.notNull(url, "'url' must not be null");
|
||||
Assert.notNull(method, "'method' must not be null");
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when an unknown (or custom) HTTP status code is received.
|
||||
@@ -42,7 +43,7 @@ public class UnknownHttpStatusCodeException extends RestClientResponseException
|
||||
* @param responseCharset the response body charset, may be {@code null}
|
||||
*/
|
||||
public UnknownHttpStatusCodeException(int rawStatusCode, String statusText,
|
||||
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
|
||||
@Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody,@Nullable Charset responseCharset) {
|
||||
|
||||
super("Unknown status code [" + String.valueOf(rawStatusCode) + "]" + " " + statusText,
|
||||
rawStatusCode, statusText, responseHeaders, responseBody, responseCharset);
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Core package of the client-side web support.
|
||||
* Provides a RestTemplate class and various callback interfaces.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.client;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Classes supporting the {@code org.springframework.web.client} package.
|
||||
* Contains a base class for RestTemplate usage.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.client.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.WebApplicationInitializer;
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,7 @@ public abstract class AbstractContextLoaderInitializer implements WebApplication
|
||||
* desired
|
||||
* @see org.springframework.web.servlet.support.AbstractDispatcherServletInitializer
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract WebApplicationContext createRootApplicationContext();
|
||||
|
||||
/**
|
||||
@@ -88,6 +90,7 @@ public abstract class AbstractContextLoaderInitializer implements WebApplication
|
||||
* @see #createRootApplicationContext()
|
||||
* @see ContextLoaderListener#setContextInitializers
|
||||
*/
|
||||
@Nullable
|
||||
protected ApplicationContextInitializer<?>[] getRootApplicationContextInitializers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by configurable web application contexts.
|
||||
@@ -69,6 +70,7 @@ public interface ConfigurableWebApplicationContext extends WebApplicationContext
|
||||
/**
|
||||
* Return the ServletConfig for this web application context, if any.
|
||||
*/
|
||||
@Nullable
|
||||
ServletConfig getServletConfig();
|
||||
|
||||
/**
|
||||
@@ -81,6 +83,7 @@ public interface ConfigurableWebApplicationContext extends WebApplicationContext
|
||||
/**
|
||||
* Return the namespace for this web application context, if any.
|
||||
*/
|
||||
@Nullable
|
||||
String getNamespace();
|
||||
|
||||
/**
|
||||
@@ -102,6 +105,7 @@ public interface ConfigurableWebApplicationContext extends WebApplicationContext
|
||||
* Return the config locations for this web application context,
|
||||
* or {@code null} if none specified.
|
||||
*/
|
||||
@Nullable
|
||||
String[] getConfigLocations();
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Specialization of {@link ConfigurableEnvironment} allowing initialization of
|
||||
@@ -43,6 +44,6 @@ public interface ConfigurableWebEnvironment extends ConfigurableEnvironment {
|
||||
* @see org.springframework.web.context.support.WebApplicationContextUtils#initServletPropertySources(
|
||||
* org.springframework.core.env.MutablePropertySources, ServletContext, ServletConfig)
|
||||
*/
|
||||
void initPropertySources(ServletContext servletContext, ServletConfig servletConfig);
|
||||
void initPropertySources(@Nullable ServletContext servletContext, @Nullable ServletConfig servletConfig);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -504,6 +506,7 @@ public class ContextLoader {
|
||||
* @param servletContext current servlet context
|
||||
* @return the parent application context, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
protected ApplicationContext loadParentContext(ServletContext servletContext) {
|
||||
return null;
|
||||
}
|
||||
@@ -542,6 +545,7 @@ public class ContextLoader {
|
||||
* if none found
|
||||
* @see org.springframework.web.context.support.SpringBeanAutowiringSupport
|
||||
*/
|
||||
@Nullable
|
||||
public static WebApplicationContext getCurrentWebApplicationContext() {
|
||||
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
|
||||
if (ccl != null) {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Provides convenience annotations for web scopes.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.context.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Contains a variant of the application context interface for web applications,
|
||||
* and the ContextLoaderListener that bootstraps a root web application context.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.web.context;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of the {@link WebRequest} interface, exposing the
|
||||
* native request and response objects in a generic fashion.
|
||||
@@ -47,6 +49,7 @@ public interface NativeWebRequest extends WebRequest {
|
||||
* of that type is available
|
||||
* @see javax.servlet.http.HttpServletRequest
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getNativeRequest(Class<T> requiredType);
|
||||
|
||||
/**
|
||||
@@ -56,6 +59,7 @@ public interface NativeWebRequest extends WebRequest {
|
||||
* of that type is available
|
||||
* @see javax.servlet.http.HttpServletResponse
|
||||
*/
|
||||
@Nullable
|
||||
<T> T getNativeResponse(Class<T> requiredType);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstraction for accessing attribute objects associated with a request.
|
||||
* Supports access to request-scoped attributes as well as to session-scoped
|
||||
@@ -63,6 +65,7 @@ public interface RequestAttributes {
|
||||
* @param scope the scope identifier
|
||||
* @return the current attribute value, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
Object getAttribute(String name, int scope);
|
||||
|
||||
/**
|
||||
@@ -122,12 +125,14 @@ public interface RequestAttributes {
|
||||
* @param key the contextual key
|
||||
* @return the corresponding object, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
Object resolveReference(String key);
|
||||
|
||||
/**
|
||||
* Return an id for the current underlying session.
|
||||
* @return the session id as String (never {@code null})
|
||||
*/
|
||||
@Nullable
|
||||
String getSessionId();
|
||||
|
||||
/**
|
||||
@@ -135,6 +140,7 @@ public interface RequestAttributes {
|
||||
* that is, an object to synchronize on for the underlying session.
|
||||
* @return the session mutex to use (never {@code null})
|
||||
*/
|
||||
@Nullable
|
||||
Object getSessionMutex();
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user