Polishing

This commit is contained in:
Juergen Hoeller
2018-07-25 14:16:02 +02:00
parent 3899b7a909
commit 3881a4aded
39 changed files with 133 additions and 147 deletions

View File

@@ -758,8 +758,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
* @see <a href="https://tools.ietf.org/html/rfc6750">RFC 6750</a>
*/
public void setBearerAuth(String token) {
Assert.notNull(token, "Token must not be null");
set(AUTHORIZATION, "Bearer " + token);
}

View File

@@ -59,8 +59,8 @@ public abstract class HttpLogging {
/**
* Wrap the given primary logger with a composite logger that delegates to
* it or to the fallback logger "org.springframework.web.HttpLogging", if
* the primary is not enabled.
* it or to the fallback logger "org.springframework.web.HttpLogging",
* if the primary is not enabled.
* @param primaryLogger the primary logger to use
* @return the resulting composite logger
*/

View File

@@ -122,6 +122,7 @@ public final class ResponseCookie extends HttpCookie {
return this.sameSite;
}
@Override
public boolean equals(Object other) {
if (this == other) {

View File

@@ -29,6 +29,7 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
/**
* Jetty ReactiveStreams HttpClient implementation of {@link ClientHttpConnector}.
@@ -60,6 +61,7 @@ public class JettyClientHttpConnector implements ClientHttpConnector, SmartLifec
* Create a Jetty {@link ClientHttpConnector} with the given {@link HttpClient}.
*/
public JettyClientHttpConnector(HttpClient httpClient) {
Assert.notNull(httpClient, "HttpClient is required");
this.httpClient = httpClient;
}
@@ -68,6 +70,7 @@ public class JettyClientHttpConnector implements ClientHttpConnector, SmartLifec
this.bufferFactory = bufferFactory;
}
@Override
public int getPhase() {
return Integer.MAX_VALUE;
@@ -110,6 +113,7 @@ public class JettyClientHttpConnector implements ClientHttpConnector, SmartLifec
callback.run();
}
@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {

View File

@@ -27,7 +27,6 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -47,8 +46,6 @@ class JettyClientHttpResponse implements ClientHttpResponse {
public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Publisher<DataBuffer> content) {
Assert.notNull(reactiveResponse, "reactiveResponse should not be null");
Assert.notNull(content, "content should not be null");
this.reactiveResponse = reactiveResponse;
this.content = Flux.from(content);
}

View File

@@ -28,6 +28,7 @@ import reactor.netty.http.client.HttpClientRequest;
import reactor.netty.http.client.HttpClientResponse;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
/**
* Reactor-Netty implementation of {@link ClientHttpConnector}.
@@ -56,6 +57,7 @@ public class ReactorClientHttpConnector implements ClientHttpConnector {
* @since 5.1
*/
public ReactorClientHttpConnector(HttpClient httpClient) {
Assert.notNull(httpClient, "HttpClient is required");
this.httpClient = httpClient;
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http.codec;
import org.apache.commons.logging.Log;

View File

@@ -458,8 +458,7 @@ public class Jackson2ObjectMapperBuilder {
* @see com.fasterxml.jackson.annotation.PropertyAccessor
* @see com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility
*/
public Jackson2ObjectMapperBuilder visibility(PropertyAccessor accessor,
JsonAutoDetect.Visibility visibility) {
public Jackson2ObjectMapperBuilder visibility(PropertyAccessor accessor, JsonAutoDetect.Visibility visibility) {
this.visibilities.put(accessor, visibility);
return this;
}

View File

@@ -83,8 +83,8 @@ public class ProtobufJsonFormatHttpMessageConverter extends ProtobufHttpMessageC
* @param parser the JSON parser configuration
* @param printer the JSON printer configuration
* @param registryInitializer an initializer for message extensions
* @deprecated as of Spring Framework 5.1, use
* {@link #ProtobufJsonFormatHttpMessageConverter(JsonFormat.Parser, JsonFormat.Printer, ExtensionRegistry)} instead
* @deprecated as of 5.1, in favor of
* {@link #ProtobufJsonFormatHttpMessageConverter(JsonFormat.Parser, JsonFormat.Printer, ExtensionRegistry)}
*/
@Deprecated
public ProtobufJsonFormatHttpMessageConverter(@Nullable JsonFormat.Parser parser,

View File

@@ -39,8 +39,8 @@ import org.springframework.util.MultiValueMap;
public interface ServerHttpRequest extends HttpRequest, ReactiveHttpInputMessage {
/**
* Return an id that represents the underlying connection, if available, or
* the request, for the purpose of correlating log messages.
* Return an id that represents the underlying connection, if available,
* or the request for the purpose of correlating log messages.
* @since 5.1
* @see org.springframework.web.server.ServerWebExchange#getLogPrefix()
*/

View File

@@ -69,10 +69,6 @@ public class FormContentFilter extends OncePerRequestFilter {
this.formConverter = converter;
}
public FormHttpMessageConverter getFormConverter() {
return this.formConverter;
}
/**
* The default character set to use for reading form data.
* This is a shortcut for:<br>

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.method;
import java.lang.annotation.Annotation;
@@ -93,10 +94,12 @@ public final class HandlerTypePredicate implements Predicate<Class<?>> {
}
private boolean hasSelectors() {
return !this.basePackages.isEmpty() || !this.assignableTypes.isEmpty() || !this.annotations.isEmpty();
return (!this.basePackages.isEmpty() || !this.assignableTypes.isEmpty() || !this.annotations.isEmpty());
}
// Static factory methods
/**
* {@code Predicate} that applies to any handlers.
*/
@@ -158,7 +161,6 @@ public final class HandlerTypePredicate implements Predicate<Class<?>> {
private final List<Class<? extends Annotation>> annotations = new ArrayList<>();
/**
* Match handlers declared under a base package, e.g. "org.example".
* @param packages one or more base package classes

View File

@@ -97,9 +97,9 @@ public class UnsupportedMediaTypeStatusException extends ResponseStatusException
/**
* Return the body type in the context of which this exception was generated.
* This is applicable when the exception was raised as a result trying to
* <p>This is applicable when the exception was raised as a result trying to
* encode from or decode to a specific Java type.
* @return the body type, or {@code null}
* @return the body type, or {@code null} if not available
* @since 5.1
*/
@Nullable

View File

@@ -62,14 +62,12 @@ public class ResponseStatusExceptionHandler implements WebExceptionHandler {
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
HttpStatus status = resolveStatus(ex);
if (status == null || !exchange.getResponse().setStatusCode(status)) {
return Mono.error(ex);
}
// Mirrors AbstractHandlerExceptionResolver in spring-webmvc..
// Mirrors AbstractHandlerExceptionResolver in spring-webmvc...
String logPrefix = exchange.getLogPrefix();
if (this.warnLogger != null && this.warnLogger.isWarnEnabled()) {
this.warnLogger.warn(logPrefix + formatError(ex, exchange.getRequest()), ex);