Polishing

This commit is contained in:
Juergen Hoeller
2018-01-19 12:30:10 +01:00
parent 4c7414833b
commit 40127bd9ad
4 changed files with 16 additions and 28 deletions

View File

@@ -108,16 +108,13 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
/**
* Subclasses must implement the actual validation of the request
* matching to declared expectations.
* @deprecated as of 5.0.3 sub-classes should implement
* {@link #matchRequest(ClientHttpRequest)} instead and return only the matched
* expectation, leaving the call to create the response as a separate step
* (to be invoked by this class).
* @deprecated as of 5.0.3, subclasses should implement {@link #matchRequest(ClientHttpRequest)}
* instead and return only the matched expectation, leaving the call to create the response
* as a separate step (to be invoked by this class).
*/
@Deprecated
@Nullable
protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request)
throws IOException {
protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException {
return null;
}
@@ -132,9 +129,8 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
* @since 5.0.3
*/
protected RequestExpectation matchRequest(ClientHttpRequest request) throws IOException {
throw new java.lang.UnsupportedOperationException(
"It looks like neither the deprecated \"validateRequestInternal\"" +
"nor its replacement (this method) are implemented.");
throw new UnsupportedOperationException("It looks like neither the deprecated \"validateRequestInternal\"" +
"nor its replacement (this method) are implemented.");
}
@Override
@@ -197,15 +193,13 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
private final Set<RequestExpectation> expectations = new LinkedHashSet<>();
public Set<RequestExpectation> getExpectations() {
return this.expectations;
}
public void addAllExpectations(Collection<RequestExpectation> expectations) {
this.expectations.addAll(expectations);
}
public Set<RequestExpectation> getExpectations() {
return this.expectations;
}
/**
* Return a matching expectation, or {@code null} if none match.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,6 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.util.NestedServletException;
/**
* Adapt {@link HttpHandler} to an {@link HttpServlet} using Servlet Async
@@ -157,11 +156,9 @@ public class ServletHttpHandlerAdapter implements Servlet {
@Override
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
if (DispatcherType.ASYNC.equals(request.getDispatcherType())) {
Throwable ex = (Throwable) request.getAttribute(WRITE_ERROR_ATTRIBUTE_NAME);
Assert.notNull(ex, "Unexpected async dispatch");
throw new NestedServletException("Write publisher error", ex);
throw new ServletException("Write publisher error", ex);
}
// Start async before Read/WriteListener registration
@@ -230,7 +227,6 @@ public class ServletHttpHandlerAdapter implements Servlet {
private final AtomicBoolean isCompleted;
public HandlerResultAsyncListener(AtomicBoolean isCompleted) {
this.isCompleted = isCompleted;
}
@@ -267,7 +263,6 @@ public class ServletHttpHandlerAdapter implements Servlet {
private final AtomicBoolean isCompleted;
public HandlerResultSubscriber(AsyncContext asyncContext, AtomicBoolean isCompleted) {
this.asyncContext = asyncContext;
this.isCompleted = isCompleted;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@ package org.springframework.web.cors.reactive;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
;
/**
* Utility class for CORS reactive request handling based on the
* <a href="http://www.w3.org/TR/cors/">CORS W3C recommendation</a>.
@@ -71,7 +70,7 @@ public abstract class CorsUtils {
return (actualHost.equals(originUrl.getHost()) && actualPort == getPort(originUrl.getScheme(), originUrl.getPort()));
}
private static int getPort(String scheme, int port) {
private static int getPort(@Nullable String scheme, int port) {
if (port == -1) {
if ("http".equals(scheme) || "ws".equals(scheme)) {
port = 80;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -754,7 +754,7 @@ public abstract class WebUtils {
return false;
}
private static int getPort(String scheme, int port) {
private static int getPort(@Nullable String scheme, int port) {
if (port == -1) {
if ("http".equals(scheme) || "ws".equals(scheme)) {
port = 80;