Rossen Stoyanchev
2017-10-20 16:41:40 -04:00
parent 8ad212dae2
commit 1cc5afe24b
197 changed files with 1688 additions and 994 deletions

View File

@@ -216,36 +216,42 @@ public enum HttpStatus {
CONFLICT(409, "Conflict"),
/**
* {@code 410 Gone}.
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.9">HTTP/1.1: Semantics and Content, section 6.5.9</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.9">
* HTTP/1.1: Semantics and Content, section 6.5.9</a>
*/
GONE(410, "Gone"),
/**
* {@code 411 Length Required}.
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.10">HTTP/1.1: Semantics and Content, section 6.5.10</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.10">
* HTTP/1.1: Semantics and Content, section 6.5.10</a>
*/
LENGTH_REQUIRED(411, "Length Required"),
/**
* {@code 412 Precondition failed}.
* @see <a href="http://tools.ietf.org/html/rfc7232#section-4.2">HTTP/1.1: Conditional Requests, section 4.2</a>
* @see <a href="http://tools.ietf.org/html/rfc7232#section-4.2">
* HTTP/1.1: Conditional Requests, section 4.2</a>
*/
PRECONDITION_FAILED(412, "Precondition Failed"),
/**
* {@code 413 Payload Too Large}.
* @since 4.1
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.11">HTTP/1.1: Semantics and Content, section 6.5.11</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.11">
* HTTP/1.1: Semantics and Content, section 6.5.11</a>
*/
PAYLOAD_TOO_LARGE(413, "Payload Too Large"),
/**
* {@code 413 Request Entity Too Large}.
* @see <a href="http://tools.ietf.org/html/rfc2616#section-10.4.14">HTTP/1.1, section 10.4.14</a>
* @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be returned from {@code HttpStatus.valueOf(413)}
* @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be
* returned from {@code HttpStatus.valueOf(413)}
*/
@Deprecated
REQUEST_ENTITY_TOO_LARGE(413, "Request Entity Too Large"),
/**
* {@code 414 URI Too Long}.
* @since 4.1
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.12">HTTP/1.1: Semantics and Content, section 6.5.12</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.12">
* HTTP/1.1: Semantics and Content, section 6.5.12</a>
*/
URI_TOO_LONG(414, "URI Too Long"),
/**
@@ -257,7 +263,8 @@ public enum HttpStatus {
REQUEST_URI_TOO_LONG(414, "Request-URI Too Long"),
/**
* {@code 415 Unsupported Media Type}.
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.13">HTTP/1.1: Semantics and Content, section 6.5.13</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.13">
* HTTP/1.1: Semantics and Content, section 6.5.13</a>
*/
UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"),
/**
@@ -267,7 +274,8 @@ public enum HttpStatus {
REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested range not satisfiable"),
/**
* {@code 417 Expectation Failed}.
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.14">HTTP/1.1: Semantics and Content, section 6.5.14</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-6.5.14">
* HTTP/1.1: Semantics and Content, section 6.5.14</a>
*/
EXPECTATION_FAILED(417, "Expectation Failed"),
/**
@@ -276,17 +284,23 @@ public enum HttpStatus {
*/
I_AM_A_TEAPOT(418, "I'm a teapot"),
/**
* @deprecated See <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a>
* @deprecated See
* <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
* WebDAV Draft Changes</a>
*/
@Deprecated
INSUFFICIENT_SPACE_ON_RESOURCE(419, "Insufficient Space On Resource"),
/**
* @deprecated See <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a>
* @deprecated See
* <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
* WebDAV Draft Changes</a>
*/
@Deprecated
METHOD_FAILURE(420, "Method Failure"),
/**
* @deprecated See <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a>
* @deprecated
* See <a href="http://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">
* WebDAV Draft Changes</a>
*/
@Deprecated
DESTINATION_LOCKED(421, "Destination Locked"),

View File

@@ -45,7 +45,8 @@ import org.springframework.util.StringUtils;
* @author Sebastien Deleuze
* @author Kazuki Shimizu
* @since 3.0
* @see <a href="http://tools.ietf.org/html/rfc7231#section-3.1.1.1">HTTP 1.1: Semantics and Content, section 3.1.1.1</a>
* @see <a href="http://tools.ietf.org/html/rfc7231#section-3.1.1.1">
* HTTP 1.1: Semantics and Content, section 3.1.1.1</a>
*/
public class MediaType extends MimeType implements Serializable {
@@ -699,7 +700,8 @@ public class MediaType extends MimeType implements Serializable {
else {
int paramsSize1 = mediaType1.getParameters().size();
int paramsSize2 = mediaType2.getParameters().size();
return (paramsSize2 < paramsSize1 ? -1 : (paramsSize2 == paramsSize1 ? 0 : 1)); // audio/basic;level=1 < audio/basic
// audio/basic;level=1 < audio/basic
return (paramsSize2 < paramsSize1 ? -1 : (paramsSize2 == paramsSize1 ? 0 : 1));
}
}
};

View File

@@ -33,7 +33,10 @@ import org.springframework.util.ObjectUtils;
* {@link org.springframework.web.client.RestTemplate#exchange(RequestEntity, Class) exchange()}:
* <pre class="code">
* MyRequest body = ...
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(new URI(&quot;http://example.com/bar&quot;)).accept(MediaType.APPLICATION_JSON).body(body);
* RequestEntity&lt;MyRequest&gt; request = RequestEntity
* .post(new URI(&quot;http://example.com/bar&quot;))
* .accept(MediaType.APPLICATION_JSON)
* .body(body);
* ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class);
* </pre>
*

View File

@@ -31,7 +31,8 @@ import org.springframework.util.concurrent.ListenableFuture;
* @author Rossen Stoyanchev
* @since 4.3
* @see AsyncClientHttpRequestInterceptor
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
*/
@Deprecated
public interface AsyncClientHttpRequestExecution {

View File

@@ -36,7 +36,8 @@ import org.springframework.util.concurrent.ListenableFuture;
* @since 4.3
* @see org.springframework.web.client.AsyncRestTemplate
* @see org.springframework.http.client.support.InterceptingAsyncHttpAccessor
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
*/
@Deprecated
public interface AsyncClientHttpRequestInterceptor {

View File

@@ -21,12 +21,14 @@ import java.io.IOException;
import org.springframework.http.HttpRequest;
/**
* Intercepts client-side HTTP requests. Implementations of this interface can be {@linkplain
* org.springframework.web.client.RestTemplate#setInterceptors(java.util.List) registered} with the
* {@link org.springframework.web.client.RestTemplate RestTemplate}, as to modify the outgoing {@link ClientHttpRequest}
* and/or the incoming {@link ClientHttpResponse}.
* Intercepts client-side HTTP requests. Implementations of this interface can be
* {@linkplain org.springframework.web.client.RestTemplate#setInterceptors(java.util.List)
* registered} with the {@link org.springframework.web.client.RestTemplate RestTemplate},
* as to modify the outgoing {@link ClientHttpRequest} and/or the incoming
* {@link ClientHttpResponse}.
*
* <p>The main entry point for interceptors is {@link #intercept(HttpRequest, byte[], ClientHttpRequestExecution)}.
* <p>The main entry point for interceptors is
* {@link #intercept(HttpRequest, byte[], ClientHttpRequestExecution)}.
*
* @author Arjen Poutsma
* @since 3.1
@@ -35,17 +37,20 @@ import org.springframework.http.HttpRequest;
public interface ClientHttpRequestInterceptor {
/**
* Intercept the given request, and return a response. The given {@link ClientHttpRequestExecution} allows
* the interceptor to pass on the request and response to the next entity in the chain.
* Intercept the given request, and return a response. The given
* {@link ClientHttpRequestExecution} allows the interceptor to pass on the
* request and response to the next entity in the chain.
*
* <p>A typical implementation of this method would follow the following pattern:
* <ol>
* <li>Examine the {@linkplain HttpRequest request} and body</li>
* <li>Optionally {@linkplain org.springframework.http.client.support.HttpRequestWrapper wrap} the request to filter HTTP attributes.</li>
* <li>Optionally {@linkplain org.springframework.http.client.support.HttpRequestWrapper
* wrap} the request to filter HTTP attributes.</li>
* <li>Optionally modify the body of the request.</li>
* <li><strong>Either</strong>
* <ul>
* <li>execute the request using {@link ClientHttpRequestExecution#execute(org.springframework.http.HttpRequest, byte[])},</li>
* <li>execute the request using
* {@link ClientHttpRequestExecution#execute(org.springframework.http.HttpRequest, byte[])},</li>
* <strong>or</strong>
* <li>do not execute the request to block the execution altogether.</li>
* </ul>

View File

@@ -160,7 +160,9 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC
}
@Override
public void addCallback(SuccessCallback<? super ClientHttpResponse> successCallback, FailureCallback failureCallback) {
public void addCallback(SuccessCallback<? super ClientHttpResponse> successCallback,
FailureCallback failureCallback) {
this.callback.addSuccessCallback(successCallback);
this.callback.addFailureCallback(failureCallback);
}

View File

@@ -50,7 +50,8 @@ import org.springframework.util.concurrent.SettableListenableFuture;
* @author Rossen Stoyanchev
* @author Brian Clozel
* @since 4.1.2
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
*/
@Deprecated
class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements ClientHttpRequest {

View File

@@ -57,7 +57,8 @@ import org.springframework.util.Assert;
* @author Brian Clozel
* @author Mark Paluch
* @since 4.1.2
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
*/
@Deprecated
public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,

View File

@@ -33,7 +33,8 @@ import org.springframework.util.Assert;
*
* @author Arjen Poutsma
* @since 4.1.2
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.http.client.reactive.ReactorClientHttpConnector}
*/
@Deprecated
class Netty4ClientHttpResponse extends AbstractClientHttpResponse {

View File

@@ -54,7 +54,9 @@ public class AsyncHttpAccessor {
* Set the request factory that this accessor uses for obtaining {@link
* org.springframework.http.client.ClientHttpRequest HttpRequests}.
*/
public void setAsyncRequestFactory(org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory) {
public void setAsyncRequestFactory(
org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory) {
Assert.notNull(asyncRequestFactory, "AsyncClientHttpRequestFactory must not be null");
this.asyncRequestFactory = asyncRequestFactory;
}

View File

@@ -99,7 +99,7 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple
return Flux.from(inputStream).map(value ->
encodeValue(value, mimeType, bufferFactory, elementType, hints));
}
else if (this.streamingMediaTypes.stream().anyMatch(streamingMediaType -> streamingMediaType.isCompatibleWith(mimeType))) {
else if (this.streamingMediaTypes.stream().anyMatch(mediaType -> mediaType.isCompatibleWith(mimeType))) {
return Flux.from(inputStream).map(value -> {
DataBuffer buffer = encodeValue(value, mimeType, bufferFactory, elementType, hints);
buffer.write(new byte[]{'\n'});

View File

@@ -79,8 +79,8 @@ public abstract class AbstractGenericHttpMessageConverter<T> extends AbstractHtt
* This implementation sets the default headers by calling {@link #addDefaultHeaders},
* and then calls {@link #writeInternal}.
*/
public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
public final void write(final T t, @Nullable final Type type, @Nullable MediaType contentType,
HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
final HttpHeaders headers = outputMessage.getHeaders();
addDefaultHeaders(headers, t, contentType);

View File

@@ -332,7 +332,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
}
}
private void writeMultipart(final MultiValueMap<String, Object> parts, HttpOutputMessage outputMessage) throws IOException {
private void writeMultipart(final MultiValueMap<String, Object> parts,
HttpOutputMessage outputMessage) throws IOException {
final byte[] boundary = generateMultipartBoundary();
Map<String, String> parameters = new HashMap<>(2);
parameters.put("boundary", new String(boundary, "US-ASCII"));

View File

@@ -49,7 +49,8 @@ import org.springframework.util.StringUtils;
* @see AtomFeedHttpMessageConverter
* @see RssChannelHttpMessageConverter
*/
public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed> extends AbstractHttpMessageConverter<T> {
public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed>
extends AbstractHttpMessageConverter<T> {
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

View File

@@ -76,10 +76,14 @@ import org.springframework.util.xml.StaxUtils;
* <p>It also automatically registers the following well-known modules if they are
* detected on the classpath:
* <ul>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>: support for other Java 8 types like {@link java.util.Optional}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>: support for Java 8 Date & Time API types</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>: support for Joda-Time types</li>
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>: support for Kotlin classes and data classes</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>:
* support for other Java 8 types like {@link java.util.Optional}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>:
* support for Java 8 Date & Time API types</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>:
* support for Joda-Time types</li>
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>:
* support for Kotlin classes and data classes</li>
* </ul>
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
@@ -766,11 +770,13 @@ public class Jackson2ObjectMapperBuilder {
if (KotlinDetector.isKotlinPresent()) {
try {
Class<? extends Module> kotlinModule = (Class<? extends Module>)
ClassUtils.forName("com.fasterxml.jackson.module.kotlin.KotlinModule", this.moduleClassLoader);
ClassUtils.forName("com.fasterxml.jackson.module.kotlin.KotlinModule",
this.moduleClassLoader);
objectMapper.registerModule(BeanUtils.instantiateClass(kotlinModule));
}
catch (ClassNotFoundException ex) {
logger.warn("For Jackson Kotlin classes support please add \"com.fasterxml.jackson.module:jackson-module-kotlin\" to the classpath");
logger.warn("For Jackson Kotlin classes support please add " +
"\"com.fasterxml.jackson.module:jackson-module-kotlin\" to the classpath");
}
}
}

View File

@@ -114,11 +114,16 @@ import org.springframework.lang.Nullable;
* <p>It also automatically registers the following well-known modules if they are
* detected on the classpath:
* <ul>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk7">jackson-datatype-jdk7</a>: support for Java 7 types like {@link java.nio.file.Path}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>: support for other Java 8 types like {@link java.util.Optional}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>: support for Java 8 Date & Time API types</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>: support for Joda-Time types</li>
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>: support for Kotlin classes and data classes</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk7">jackson-datatype-jdk7</a>:
* support for Java 7 types like {@link java.nio.file.Path}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jdk8">jackson-datatype-jdk8</a>:
* support for other Java 8 types like {@link java.util.Optional}</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-jsr310">jackson-datatype-jsr310</a>:
* support for Java 8 Date & Time API types</li>
* <li><a href="https://github.com/FasterXML/jackson-datatype-joda">jackson-datatype-joda</a>:
* support for Joda-Time types</li>
* <li><a href="https://github.com/FasterXML/jackson-module-kotlin">jackson-module-kotlin</a>:
* support for Kotlin classes and data classes</li>
* </ul>
*
* <p>In case you want to configure Jackson's {@link ObjectMapper} with a custom {@link Module},

View File

@@ -70,22 +70,30 @@ public class SpringHandlerInstantiator extends HandlerInstantiator {
@Override
public JsonDeserializer<?> deserializerInstance(DeserializationConfig config, Annotated annotated, Class<?> implClass) {
public JsonDeserializer<?> deserializerInstance(DeserializationConfig config,
Annotated annotated, Class<?> implClass) {
return (JsonDeserializer<?>) this.beanFactory.createBean(implClass);
}
@Override
public KeyDeserializer keyDeserializerInstance(DeserializationConfig config, Annotated annotated, Class<?> implClass) {
public KeyDeserializer keyDeserializerInstance(DeserializationConfig config,
Annotated annotated, Class<?> implClass) {
return (KeyDeserializer) this.beanFactory.createBean(implClass);
}
@Override
public JsonSerializer<?> serializerInstance(SerializationConfig config, Annotated annotated, Class<?> implClass) {
public JsonSerializer<?> serializerInstance(SerializationConfig config,
Annotated annotated, Class<?> implClass) {
return (JsonSerializer<?>) this.beanFactory.createBean(implClass);
}
@Override
public TypeResolverBuilder<?> typeResolverBuilderInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public TypeResolverBuilder<?> typeResolverBuilderInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (TypeResolverBuilder<?>) this.beanFactory.createBean(implClass);
}
@@ -96,31 +104,41 @@ public class SpringHandlerInstantiator extends HandlerInstantiator {
/** @since 4.3 */
@Override
public ValueInstantiator valueInstantiatorInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public ValueInstantiator valueInstantiatorInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (ValueInstantiator) this.beanFactory.createBean(implClass);
}
/** @since 4.3 */
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (ObjectIdGenerator<?>) this.beanFactory.createBean(implClass);
}
/** @since 4.3 */
@Override
public ObjectIdResolver resolverIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public ObjectIdResolver resolverIdGeneratorInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (ObjectIdResolver) this.beanFactory.createBean(implClass);
}
/** @since 4.3 */
@Override
public PropertyNamingStrategy namingStrategyInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public PropertyNamingStrategy namingStrategyInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (PropertyNamingStrategy) this.beanFactory.createBean(implClass);
}
/** @since 4.3 */
@Override
public Converter<?, ?> converterInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
public Converter<?, ?> converterInstance(MapperConfig<?> config,
Annotated annotated, Class<?> implClass) {
return (Converter<?, ?>) this.beanFactory.createBean(implClass);
}

View File

@@ -40,20 +40,26 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
ClassUtils.isPresent("javax.xml.bind.Binder", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
private static final boolean jackson2Present =
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", AllEncompassingFormHttpMessageConverter.class.getClassLoader()) &&
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
AllEncompassingFormHttpMessageConverter.class.getClassLoader()) &&
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
private static final boolean jackson2XmlPresent =
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper",
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
private static final boolean jackson2SmilePresent =
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.smile.SmileFactory",
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
private static final boolean gsonPresent =
ClassUtils.isPresent("com.google.gson.Gson", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
ClassUtils.isPresent("com.google.gson.Gson",
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
private static final boolean jsonbPresent =
ClassUtils.isPresent("javax.json.bind.Jsonb", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
ClassUtils.isPresent("javax.json.bind.Jsonb",
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
public AllEncompassingFormHttpMessageConverter() {

View File

@@ -50,7 +50,8 @@ public class HttpMediaTypeNotSupportedException extends HttpMediaTypeException {
* @param supportedMediaTypes the list of supported media types
*/
public HttpMediaTypeNotSupportedException(@Nullable MediaType contentType, List<MediaType> supportedMediaTypes) {
this(contentType, supportedMediaTypes, "Content type '" + (contentType != null ? contentType : "") + "' not supported");
this(contentType, supportedMediaTypes, "Content type '" +
(contentType != null ? contentType : "") + "' not supported");
}
/**
@@ -59,7 +60,9 @@ public class HttpMediaTypeNotSupportedException extends HttpMediaTypeException {
* @param supportedMediaTypes the list of supported media types
* @param msg the detail message
*/
public HttpMediaTypeNotSupportedException(@Nullable MediaType contentType, List<MediaType> supportedMediaTypes, String msg) {
public HttpMediaTypeNotSupportedException(@Nullable MediaType contentType,
List<MediaType> supportedMediaTypes, String msg) {
super(msg, supportedMediaTypes);
this.contentType = contentType;
}

View File

@@ -110,7 +110,9 @@ public class EscapedErrors implements Errors {
}
@Override
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs,
@Nullable String defaultMessage) {
this.source.rejectValue(field, errorCode, errorArgs, defaultMessage);
}

View File

@@ -19,15 +19,18 @@ package org.springframework.web.client;
import java.io.IOException;
/**
* Callback interface for code that operates on an {@link org.springframework.http.client.AsyncClientHttpRequest}. Allows
* to manipulate the request headers, and write to the request body.
* Callback interface for code that operates on an
* {@link org.springframework.http.client.AsyncClientHttpRequest}. Allows to
* manipulate the request headers, and write to the request body.
*
* <p>Used internally by the {@link AsyncRestTemplate}, but also useful for application code.
* <p>Used internally by the {@link AsyncRestTemplate}, but also useful for
* application code.
*
* @author Arjen Poutsma
* @see org.springframework.web.client.AsyncRestTemplate#execute
* @since 4.0
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
* @deprecated as of Spring 5.0, in favor of
* {@link org.springframework.web.reactive.function.client.ExchangeFilterFunction}
*/
@FunctionalInterface
@Deprecated

View File

@@ -347,8 +347,11 @@ public interface AsyncRestOperations {
* The given {@link ParameterizedTypeReference} is used to pass generic type
* information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
@@ -368,8 +371,11 @@ public interface AsyncRestOperations {
* The given {@link ParameterizedTypeReference} is used to pass generic type
* information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
@@ -389,8 +395,11 @@ public interface AsyncRestOperations {
* The given {@link ParameterizedTypeReference} is used to pass generic type
* information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)

View File

@@ -67,7 +67,8 @@ import org.springframework.web.util.UriTemplateHandler;
* @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.WebClient}
*/
@Deprecated
public class AsyncRestTemplate extends org.springframework.http.client.support.InterceptingAsyncHttpAccessor implements AsyncRestOperations {
public class AsyncRestTemplate extends org.springframework.http.client.support.InterceptingAsyncHttpAccessor
implements AsyncRestOperations {
private final RestTemplate syncTemplate;
@@ -114,8 +115,8 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
* @param asyncRequestFactory the asynchronous request factory
* @param syncRequestFactory the synchronous request factory
*/
public AsyncRestTemplate(
org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory, ClientHttpRequestFactory syncRequestFactory) {
public AsyncRestTemplate(org.springframework.http.client.AsyncClientHttpRequestFactory asyncRequestFactory,
ClientHttpRequestFactory syncRequestFactory) {
this(asyncRequestFactory, new RestTemplate(syncRequestFactory));
}
@@ -126,7 +127,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
* @param requestFactory the asynchronous request factory to use
* @param restTemplate the synchronous template to use
*/
public AsyncRestTemplate(org.springframework.http.client.AsyncClientHttpRequestFactory requestFactory, RestTemplate restTemplate) {
public AsyncRestTemplate(org.springframework.http.client.AsyncClientHttpRequestFactory requestFactory,
RestTemplate restTemplate) {
Assert.notNull(restTemplate, "RestTemplate must not be null");
this.syncTemplate = restTemplate;
setAsyncRequestFactory(requestFactory);
@@ -236,7 +239,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(URI url, Class<T> responseType) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> getForEntity(URI url, Class<T> responseType)
throws RestClientException {
AsyncRequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
@@ -246,13 +251,17 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
// HEAD
@Override
public ListenableFuture<HttpHeaders> headForHeaders(String url, Object... uriVariables) throws RestClientException {
public ListenableFuture<HttpHeaders> headForHeaders(String url, Object... uriVariables)
throws RestClientException {
ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
return execute(url, HttpMethod.HEAD, null, headersExtractor, uriVariables);
}
@Override
public ListenableFuture<HttpHeaders> headForHeaders(String url, Map<String, ?> uriVariables) throws RestClientException {
public ListenableFuture<HttpHeaders> headForHeaders(String url, Map<String, ?> uriVariables)
throws RestClientException {
ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
return execute(url, HttpMethod.HEAD, null, headersExtractor, uriVariables);
}
@@ -287,7 +296,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public ListenableFuture<URI> postForLocation(URI url, @Nullable HttpEntity<?> request) throws RestClientException {
public ListenableFuture<URI> postForLocation(URI url, @Nullable HttpEntity<?> request)
throws RestClientException {
AsyncRequestCallback callback = httpEntityCallback(request);
ResponseExtractor<HttpHeaders> extractor = headersExtractor();
ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.POST, callback, extractor);
@@ -323,8 +334,8 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url, @Nullable HttpEntity<?> request, Class<T> responseType)
throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> postForEntity(URI url,
@Nullable HttpEntity<?> request, Class<T> responseType) throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -335,15 +346,19 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
// PUT
@Override
public ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Object... uriVariables) throws RestClientException {
public ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Object... uriVars)
throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVars);
}
@Override
public ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Map<String, ?> uriVariables) throws RestClientException {
public ListenableFuture<?> put(String url, @Nullable HttpEntity<?> request, Map<String, ?> uriVars)
throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(request);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
return execute(url, HttpMethod.PUT, requestCallback, null, uriVars);
}
@Override
@@ -374,14 +389,18 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
// OPTIONS
@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Object... uriVars) throws RestClientException {
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Object... uriVars)
throws RestClientException {
ResponseExtractor<HttpHeaders> extractor = headersExtractor();
ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.OPTIONS, null, extractor, uriVars);
return adaptToAllowHeader(future);
}
@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Map<String, ?> uriVars) throws RestClientException {
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Map<String, ?> uriVars)
throws RestClientException {
ResponseExtractor<HttpHeaders> extractor = headersExtractor();
ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.OPTIONS, null, extractor, uriVars);
return adaptToAllowHeader(future);
@@ -406,8 +425,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
// exchange
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
Class<T> responseType, Object... uriVariables) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables)
throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -415,8 +435,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -424,8 +445,8 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
Class<T> responseType) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, Class<T> responseType) throws RestClientException {
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -433,8 +454,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
Object... uriVariables) throws RestClientException {
Type type = responseType.getType();
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, type);
@@ -443,8 +465,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType,
Map<String, ?> uriVariables) throws RestClientException {
Type type = responseType.getType();
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, type);
@@ -453,8 +476,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType) throws RestClientException {
public <T> ListenableFuture<ResponseEntity<T>> exchange(URI url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
throws RestClientException {
Type type = responseType.getType();
AsyncRequestCallback requestCallback = httpEntityCallback(requestEntity, type);
@@ -474,15 +498,17 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public <T> ListenableFuture<T> execute(String url, HttpMethod method, @Nullable AsyncRequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException {
public <T> ListenableFuture<T> execute(String url, HttpMethod method,
@Nullable AsyncRequestCallback requestCallback, @Nullable ResponseExtractor<T> responseExtractor,
Map<String, ?> uriVariables) throws RestClientException {
URI expanded = getUriTemplateHandler().expand(url, uriVariables);
return doExecute(expanded, method, requestCallback, responseExtractor);
}
@Override
public <T> ListenableFuture<T> execute(URI url, HttpMethod method, @Nullable AsyncRequestCallback requestCallback,
public <T> ListenableFuture<T> execute(URI url, HttpMethod method,
@Nullable AsyncRequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
return doExecute(url, method, requestCallback, responseExtractor);
@@ -500,7 +526,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, @Nullable AsyncRequestCallback requestCallback,
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");
@@ -651,7 +678,9 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
}
@Override
public void doWithRequest(final org.springframework.http.client.AsyncClientHttpRequest request) throws IOException {
public void doWithRequest(final org.springframework.http.client.AsyncClientHttpRequest request)
throws IOException {
this.adaptee.doWithRequest(new ClientHttpRequest() {
@Override
public ClientHttpResponse execute() throws IOException {

View File

@@ -87,7 +87,8 @@ public interface RestOperations {
* @return the entity
* @since 3.0.2
*/
<T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... uriVariables) throws RestClientException;
<T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... uriVariables)
throws RestClientException;
/**
* Retrieve a representation by doing a GET on the URI template.
@@ -99,7 +100,8 @@ public interface RestOperations {
* @return the converted object
* @since 3.0.2
*/
<T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
<T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException;
/**
* Retrieve a representation by doing a GET on the URL .
@@ -170,7 +172,8 @@ public interface RestOperations {
* @see HttpEntity
*/
@Nullable
URI postForLocation(String url, @Nullable 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
@@ -199,8 +202,8 @@ public interface RestOperations {
* @see HttpEntity
*/
@Nullable
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException;
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException;
/**
* Create a new resource by POSTing the given object to the URI template,
@@ -216,8 +219,8 @@ public interface RestOperations {
* @see HttpEntity
*/
@Nullable
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException;
<T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
/**
* Create a new resource by POSTing the given object to the URL,
@@ -246,8 +249,8 @@ public interface RestOperations {
* @since 3.0.2
* @see HttpEntity
*/
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException;
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException;
/**
* Create a new resource by POSTing the given object to the URI template,
@@ -262,8 +265,8 @@ public interface RestOperations {
* @since 3.0.2
* @see HttpEntity
*/
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException;
<T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
/**
* Create a new resource by POSTing the given object to the URL,
@@ -276,7 +279,8 @@ public interface RestOperations {
* @since 3.0.2
* @see HttpEntity
*/
<T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException;
<T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType)
throws RestClientException;
// PUT
@@ -361,8 +365,8 @@ public interface RestOperations {
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/
@Nullable
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException;
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
/**
* Update a resource by PATCHing the given object to the URL,
@@ -382,7 +386,8 @@ public interface RestOperations {
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/
@Nullable
<T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException;
<T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType)
throws RestClientException;
@@ -493,8 +498,11 @@ public interface RestOperations {
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
@@ -513,8 +521,11 @@ public interface RestOperations {
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
@@ -533,8 +544,11 @@ public interface RestOperations {
* request entity to the request, and returns the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
*
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response =
* template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
* </pre>
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
@@ -553,7 +567,10 @@ public interface RestOperations {
* with the static builder methods on {@code RequestEntity}, for instance:
* <pre class="code">
* MyRequest body = ...
* RequestEntity request = RequestEntity.post(new URI(&quot;http://example.com/foo&quot;)).accept(MediaType.APPLICATION_JSON).body(body);
* RequestEntity request = RequestEntity
* .post(new URI(&quot;http://example.com/foo&quot;))
* .accept(MediaType.APPLICATION_JSON)
* .body(body);
* ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class);
* </pre>
* @param requestEntity the entity to write to the request
@@ -561,7 +578,8 @@ public interface RestOperations {
* @return the response as entity
* @since 4.1
*/
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType) throws RestClientException;
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
throws RestClientException;
/**
* Execute the request specified in the given {@link RequestEntity} and return
@@ -569,8 +587,12 @@ public interface RestOperations {
* {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code">
* MyRequest body = ...
* RequestEntity request = RequestEntity.post(new URI(&quot;http://example.com/foo&quot;)).accept(MediaType.APPLICATION_JSON).body(body);
* ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt;() {};
* RequestEntity request = RequestEntity
* .post(new URI(&quot;http://example.com/foo&quot;))
* .accept(MediaType.APPLICATION_JSON)
* .body(body);
* ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt; myBean =
* new ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyResponse&gt;&gt; response = template.exchange(request, myBean);
* </pre>
* @param requestEntity the entity to write to the request
@@ -597,7 +619,8 @@ public interface RestOperations {
*/
@Nullable
<T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException;
@Nullable ResponseExtractor<T> responseExtractor, Object... uriVariables)
throws RestClientException;
/**
* Execute the HTTP method to the given URI template, preparing the request with the
@@ -612,7 +635,8 @@ public interface RestOperations {
*/
@Nullable
<T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException;
@Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables)
throws RestClientException;
/**
* Execute the HTTP method to the given URL, preparing the request with the

View File

@@ -385,7 +385,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public URI postForLocation(String url, @Nullable Object request, Object... uriVariables) throws RestClientException {
public URI postForLocation(String url, @Nullable Object request, Object... uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request);
HttpHeaders headers = execute(url, HttpMethod.POST, requestCallback, headersExtractor(), uriVariables);
return (headers != null ? headers.getLocation() : null);
@@ -393,7 +395,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public URI postForLocation(String url, @Nullable Object request, Map<String, ?> uriVariables) throws RestClientException {
public URI postForLocation(String url, @Nullable Object request, Map<String, ?> uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request);
HttpHeaders headers = execute(url, HttpMethod.POST, requestCallback, headersExtractor(), uriVariables);
return (headers != null ? headers.getLocation() : null);
@@ -409,8 +413,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException {
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
@@ -420,8 +424,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
@@ -431,7 +435,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public <T> T postForObject(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException {
public <T> T postForObject(URI url, @Nullable Object request, Class<T> responseType)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
HttpMessageConverterExtractor<T> responseExtractor =
new HttpMessageConverterExtractor<>(responseType, getMessageConverters());
@@ -439,8 +445,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
@Override
public <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException {
public <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request,
Class<T> responseType, Object... uriVariables) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -448,8 +454,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
@Override
public <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
public <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request,
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -457,7 +463,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
@Override
public <T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType) throws RestClientException {
public <T> ResponseEntity<T> postForEntity(URI url, @Nullable Object request, Class<T> responseType)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
return nonNull(execute(url, HttpMethod.POST, requestCallback, responseExtractor));
@@ -467,13 +475,17 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
// PUT
@Override
public void put(String url, @Nullable Object request, Object... uriVariables) throws RestClientException {
public void put(String url, @Nullable Object request, Object... uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request);
execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
}
@Override
public void put(String url, @Nullable Object request, Map<String, ?> uriVariables) throws RestClientException {
public void put(String url, @Nullable Object request, Map<String, ?> uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request);
execute(url, HttpMethod.PUT, requestCallback, null, uriVariables);
}
@@ -567,7 +579,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
public <T> ResponseEntity<T> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException {
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -576,7 +589,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
public <T> ResponseEntity<T> exchange(String url, HttpMethod method,
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
@Nullable HttpEntity<?> requestEntity, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);
@@ -660,7 +674,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
@Override
@Nullable
public <T> T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
@Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException {
@Nullable ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables)
throws RestClientException {
URI expanded = getUriTemplateHandler().expand(url, uriVariables);
return doExecute(expanded, method, requestCallback, responseExtractor);
@@ -898,8 +913,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
MediaType requestContentType = requestHeaders.getContentType();
for (HttpMessageConverter<?> messageConverter : getMessageConverters()) {
if (messageConverter instanceof GenericHttpMessageConverter) {
GenericHttpMessageConverter<Object> genericMessageConverter = (GenericHttpMessageConverter<Object>) messageConverter;
if (genericMessageConverter.canWrite(requestBodyType, requestBodyClass, requestContentType)) {
GenericHttpMessageConverter<Object> genericConverter =
(GenericHttpMessageConverter<Object>) messageConverter;
if (genericConverter.canWrite(requestBodyType, requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
httpRequest.getHeaders().putAll(requestHeaders);
}
@@ -913,8 +929,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
}
genericMessageConverter.write(
requestBody, requestBodyType, requestContentType, httpRequest);
genericConverter.write(requestBody, requestBodyType, requestContentType, httpRequest);
return;
}
}

View File

@@ -42,7 +42,9 @@ class DeferredResultInterceptorChain {
this.interceptors = interceptors;
}
public void applyBeforeConcurrentHandling(NativeWebRequest request, DeferredResult<?> deferredResult) throws Exception {
public void applyBeforeConcurrentHandling(NativeWebRequest request, DeferredResult<?> deferredResult)
throws Exception {
for (DeferredResultProcessingInterceptor interceptor : this.interceptors) {
interceptor.beforeConcurrentHandling(request, deferredResult);
}
@@ -55,7 +57,9 @@ class DeferredResultInterceptorChain {
}
}
public Object applyPostProcess(NativeWebRequest request, DeferredResult<?> deferredResult, Object concurrentResult) {
public Object applyPostProcess(NativeWebRequest request, DeferredResult<?> deferredResult,
Object concurrentResult) {
try {
for (int i = this.preProcessingIndex; i >= 0; i--) {
this.interceptors.get(i).postProcess(request, deferredResult, concurrentResult);
@@ -78,12 +82,14 @@ class DeferredResultInterceptorChain {
}
}
public void triggerAfterError(NativeWebRequest request, DeferredResult<?> deferredResult, Throwable t) throws Exception {
public void triggerAfterError(NativeWebRequest request, DeferredResult<?> deferredResult, Throwable ex)
throws Exception {
for (DeferredResultProcessingInterceptor interceptor : this.interceptors) {
if (deferredResult.isSetOrExpired()) {
return;
}
if (!interceptor.handleError(request, deferredResult, t)){
if (!interceptor.handleError(request, deferredResult, ex)){
break;
}
}

View File

@@ -270,7 +270,9 @@ public final class WebAsyncManager {
* via {@link #getConcurrentResultContext()}
* @throws Exception if concurrent processing failed to start
*/
public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object... processingContext) throws Exception {
public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object... processingContext)
throws Exception {
Assert.notNull(webAsyncTask, "WebAsyncTask must not be null");
Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null");

View File

@@ -61,7 +61,9 @@ public class RequestHandledEvent extends ApplicationEvent {
* request, if any (usually the UserPrincipal)
* @param processingTimeMillis the processing time of the request in milliseconds
*/
public RequestHandledEvent(Object source, @Nullable String sessionId, @Nullable String userName, long processingTimeMillis) {
public RequestHandledEvent(Object source, @Nullable String sessionId, @Nullable String userName,
long processingTimeMillis) {
super(source);
this.sessionId = sessionId;
this.userName = userName;
@@ -77,8 +79,8 @@ public class RequestHandledEvent extends ApplicationEvent {
* @param processingTimeMillis the processing time of the request in milliseconds
* @param failureCause the cause of failure, if any
*/
public RequestHandledEvent(
Object source, @Nullable String sessionId, @Nullable String userName, long processingTimeMillis, @Nullable Throwable failureCause) {
public RequestHandledEvent(Object source, @Nullable String sessionId, @Nullable String userName,
long processingTimeMillis, @Nullable Throwable failureCause) {
this(source, sessionId, userName, processingTimeMillis);
this.failureCause = failureCause;

View File

@@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.ServletConfig;
@@ -180,7 +179,9 @@ public abstract class WebApplicationContextUtils {
* @param beanFactory the BeanFactory to configure
* @param sc the ServletContext that we're running within
*/
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, @Nullable ServletContext sc) {
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory,
@Nullable ServletContext sc) {
beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope());
if (sc != null) {
@@ -278,7 +279,7 @@ public abstract class WebApplicationContextUtils {
* <p>This method is idempotent with respect to the fact it may be called any number
* of times but will perform replacement of stub property sources with their
* corresponding actual property sources once and only once.
* @param propertySources the {@link MutablePropertySources} to initialize (must not
* @param sources the {@link MutablePropertySources} to initialize (must not
* be {@code null})
* @param servletContext the current {@link ServletContext} (ignored if {@code null}
* or if the {@link StandardServletEnvironment#SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
@@ -289,19 +290,17 @@ public abstract class WebApplicationContextUtils {
* @see org.springframework.core.env.PropertySource.StubPropertySource
* @see org.springframework.core.env.ConfigurableEnvironment#getPropertySources()
*/
public static void initServletPropertySources(
MutablePropertySources propertySources, @Nullable ServletContext servletContext, @Nullable ServletConfig servletConfig) {
public static void initServletPropertySources(MutablePropertySources sources,
@Nullable ServletContext servletContext, @Nullable ServletConfig servletConfig) {
Assert.notNull(propertySources, "'propertySources' must not be null");
if (servletContext != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) &&
propertySources.get(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
propertySources.replace(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
new ServletContextPropertySource(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
Assert.notNull(sources, "'propertySources' must not be null");
String name = StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME;
if (servletContext != null && sources.contains(name) && sources.get(name) instanceof StubPropertySource) {
sources.replace(name, new ServletContextPropertySource(name, servletContext));
}
if (servletConfig != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) &&
propertySources.get(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
propertySources.replace(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
new ServletConfigPropertySource(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
name = StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME;
if (servletConfig != null && sources.contains(name) && sources.get(name) instanceof StubPropertySource) {
sources.replace(name, new ServletConfigPropertySource(name, servletConfig));
}
}

View File

@@ -58,8 +58,8 @@ public class DefaultCorsProcessor implements CorsProcessor {
@Override
@SuppressWarnings("resource")
public boolean processRequest(@Nullable CorsConfiguration config, HttpServletRequest request, HttpServletResponse response)
throws IOException {
public boolean processRequest(@Nullable CorsConfiguration config, HttpServletRequest request,
HttpServletResponse response) throws IOException {
if (!CorsUtils.isCorsRequest(request)) {
return true;

View File

@@ -98,8 +98,8 @@ public abstract class DecoratingNavigationHandler extends NavigationHandler {
* or {@code null} if none
* @see #callNextHandlerInChain
*/
public abstract void handleNavigation(
FacesContext facesContext, @Nullable String fromAction, @Nullable String outcome, @Nullable NavigationHandler originalNavigationHandler);
public abstract void handleNavigation(FacesContext facesContext, @Nullable String fromAction,
@Nullable String outcome, @Nullable NavigationHandler originalNavigationHandler);
/**
@@ -130,8 +130,8 @@ public abstract class DecoratingNavigationHandler extends NavigationHandler {
* @param originalNavigationHandler the original NavigationHandler,
* or {@code null} if none
*/
protected final void callNextHandlerInChain(
FacesContext facesContext, @Nullable String fromAction, @Nullable String outcome, @Nullable NavigationHandler originalNavigationHandler) {
protected final void callNextHandlerInChain(FacesContext facesContext, @Nullable String fromAction,
@Nullable String outcome, @Nullable NavigationHandler originalNavigationHandler) {
NavigationHandler decoratedNavigationHandler = getDecoratedNavigationHandler();

View File

@@ -100,7 +100,9 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
* is treated as a request parameter even if it isn't annotated, the
* request parameter name is derived from the method parameter name.
*/
public RequestParamMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory, boolean useDefaultResolution) {
public RequestParamMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory,
boolean useDefaultResolution) {
super(beanFactory);
this.useDefaultResolution = useDefaultResolution;
}

View File

@@ -72,7 +72,9 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
/**
* Add the given {@link HandlerMethodArgumentResolver}s.
*/
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable List<? extends HandlerMethodArgumentResolver> resolvers) {
public HandlerMethodArgumentResolverComposite addResolvers(
@Nullable List<? extends HandlerMethodArgumentResolver> resolvers) {
if (resolvers != null) {
for (HandlerMethodArgumentResolver resolver : resolvers) {
this.argumentResolvers.add(resolver);

View File

@@ -76,7 +76,9 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
* first access of multipart files or parameters
* @throws MultipartException if an immediate parsing attempt failed
*/
public StandardMultipartHttpServletRequest(HttpServletRequest request, boolean lazyParsing) throws MultipartException {
public StandardMultipartHttpServletRequest(HttpServletRequest request,
boolean lazyParsing) throws MultipartException {
super(request);
if (!lazyParsing) {
parseRequest(request);

View File

@@ -73,13 +73,16 @@ public abstract class ServletContextPropertyUtils {
* @see SystemPropertyUtils#resolvePlaceholders(String, boolean)
* @throws IllegalArgumentException if there is an unresolvable placeholder and the flag is false
*/
public static String resolvePlaceholders(String text, ServletContext servletContext, boolean ignoreUnresolvablePlaceholders) {
public static String resolvePlaceholders(String text, ServletContext servletContext,
boolean ignoreUnresolvablePlaceholders) {
PropertyPlaceholderHelper helper = (ignoreUnresolvablePlaceholders ? nonStrictHelper : strictHelper);
return helper.replacePlaceholders(text, new ServletContextPlaceholderResolver(text, servletContext));
}
private static class ServletContextPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
private static class ServletContextPlaceholderResolver
implements PropertyPlaceholderHelper.PlaceholderResolver {
private final String text;

View File

@@ -125,11 +125,14 @@ public abstract class TagUtils {
* type-assignable to the {@link Tag} class
* @see #hasAncestorOfType(javax.servlet.jsp.tagext.Tag, Class)
*/
public static void assertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName, String ancestorTagName) {
public static void assertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName,
String ancestorTagName) {
Assert.hasText(tagName, "'tagName' must not be empty");
Assert.hasText(ancestorTagName, "'ancestorTagName' must not be empty");
if (!TagUtils.hasAncestorOfType(tag, ancestorTagClass)) {
throw new IllegalStateException("The '" + tagName + "' tag can only be used inside a valid '" + ancestorTagName + "' tag.");
throw new IllegalStateException("The '" + tagName +
"' tag can only be used inside a valid '" + ancestorTagName + "' tag.");
}
}

View File

@@ -229,8 +229,11 @@ public abstract class UriUtils {
* @return the encoded query parameter
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
*/
public static String encodeQueryParam(String queryParam, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(queryParam, encoding, HierarchicalUriComponents.Type.QUERY_PARAM);
public static String encodeQueryParam(String queryParam, String encoding)
throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(
queryParam, encoding, HierarchicalUriComponents.Type.QUERY_PARAM);
}
/**
@@ -241,7 +244,8 @@ public abstract class UriUtils {
* @since 5.0
*/
public static String encodeQueryParam(String queryParam, Charset charset) {
return HierarchicalUriComponents.encodeUriComponent(queryParam, charset, HierarchicalUriComponents.Type.QUERY_PARAM);
return HierarchicalUriComponents.encodeUriComponent(
queryParam, charset, HierarchicalUriComponents.Type.QUERY_PARAM);
}
/**
@@ -251,8 +255,11 @@ public abstract class UriUtils {
* @return the encoded fragment
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
*/
public static String encodeFragment(String fragment, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(fragment, encoding, HierarchicalUriComponents.Type.FRAGMENT);
public static String encodeFragment(String fragment, String encoding)
throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(
fragment, encoding, HierarchicalUriComponents.Type.FRAGMENT);
}
/**

View File

@@ -554,7 +554,9 @@ public class UrlPathHelper {
* @param vars URI variables extracted from the URL path
* @return the same Map or a new Map instance
*/
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, MultiValueMap<String, String> vars) {
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request,
MultiValueMap<String, String> vars) {
if (this.urlDecode) {
return vars;
}

View File

@@ -435,7 +435,9 @@ public abstract class WebUtils {
* @param ex the exception encountered
* @param servletName the name of the offending servlet
*/
public static void exposeErrorRequestAttributes(HttpServletRequest request, Throwable ex, @Nullable String servletName) {
public static void exposeErrorRequestAttributes(HttpServletRequest request, Throwable ex,
@Nullable String servletName) {
exposeRequestAttributeIfNotPresent(request, ERROR_STATUS_CODE_ATTRIBUTE, HttpServletResponse.SC_OK);
exposeRequestAttributeIfNotPresent(request, ERROR_EXCEPTION_TYPE_ATTRIBUTE, ex.getClass());
exposeRequestAttributeIfNotPresent(request, ERROR_MESSAGE_ATTRIBUTE, ex.getMessage());

View File

@@ -82,7 +82,8 @@ class CaptureVariablePathElement extends PathElement {
}
if (this.constraintPattern != null) {
// TODO possible optimization - only regex match if rest of pattern matches? Benefit likely to vary pattern to pattern
// TODO possible optimization - only regex match if rest of pattern matches?
// Benefit likely to vary pattern to pattern
Matcher matcher = constraintPattern.matcher(candidateCapture);
if (matcher.groupCount() != 0) {
throw new IllegalArgumentException(
@@ -117,7 +118,8 @@ class CaptureVariablePathElement extends PathElement {
}
if (match && matchingContext.extractingVariables) {
matchingContext.set(this.variableName, candidateCapture, ((PathSegment)matchingContext.pathElements.get(pathIndex-1)).parameters());
matchingContext.set(this.variableName, candidateCapture,
((PathSegment)matchingContext.pathElements.get(pathIndex-1)).parameters());
}
return match;
}

View File

@@ -381,7 +381,9 @@ public class PathPattern implements Comparable<PathPattern> {
// /hotels/* + /booking => /hotels/booking
// /hotels/* + booking => /hotels/booking
if (this.endsWithSeparatorWildcard) {
return parser.parse(concat(this.patternString.substring(0, this.patternString.length() - 2), pattern2string.patternString));
return parser.parse(concat(
this.patternString.substring(0, this.patternString.length() - 2),
pattern2string.patternString));
}
// /hotels + /booking => /hotels/booking

View File

@@ -98,8 +98,8 @@ public class PatternParseException extends IllegalArgumentException {
MISSING_OPEN_CAPTURE("Missing preceeding open capture character before variable name'{'"),
ILLEGAL_NESTED_CAPTURE("Not allowed to nest variable captures"),
CANNOT_HAVE_ADJACENT_CAPTURES("Adjacent captures are not allowed"),
ILLEGAL_CHARACTER_AT_START_OF_CAPTURE_DESCRIPTOR("Character ''{0}'' is not allowed at start of captured variable name"),
ILLEGAL_CHARACTER_IN_CAPTURE_DESCRIPTOR("Character ''{0}'' is not allowed in a captured variable name"),
ILLEGAL_CHARACTER_AT_START_OF_CAPTURE_DESCRIPTOR("Char ''{0}'' not allowed at start of captured variable name"),
ILLEGAL_CHARACTER_IN_CAPTURE_DESCRIPTOR("Char ''{0}'' is not allowed in a captured variable name"),
NO_MORE_DATA_EXPECTED_AFTER_CAPTURE_THE_REST("No more pattern data allowed after '{*...}' pattern element"),
BADLY_FORMED_CAPTURE_THE_REST("Expected form when capturing the rest of the path is simply '{*...}'"),
MISSING_REGEX_CONSTRAINT("Missing regex constraint on capture"),