Skip to content

Commit 40127bd

Browse files
committed
Polishing
1 parent 4c74148 commit 40127bd

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java

+9-15
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,13 @@ protected void afterExpectationsDeclared() {
108108
/**
109109
* Subclasses must implement the actual validation of the request
110110
* matching to declared expectations.
111-
* @deprecated as of 5.0.3 sub-classes should implement
112-
* {@link #matchRequest(ClientHttpRequest)} instead and return only the matched
113-
* expectation, leaving the call to create the response as a separate step
114-
* (to be invoked by this class).
111+
* @deprecated as of 5.0.3, subclasses should implement {@link #matchRequest(ClientHttpRequest)}
112+
* instead and return only the matched expectation, leaving the call to create the response
113+
* as a separate step (to be invoked by this class).
115114
*/
116115
@Deprecated
117116
@Nullable
118-
protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request)
119-
throws IOException {
120-
117+
protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException {
121118
return null;
122119
}
123120

@@ -132,9 +129,8 @@ protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request)
132129
* @since 5.0.3
133130
*/
134131
protected RequestExpectation matchRequest(ClientHttpRequest request) throws IOException {
135-
throw new java.lang.UnsupportedOperationException(
136-
"It looks like neither the deprecated \"validateRequestInternal\"" +
137-
"nor its replacement (this method) are implemented.");
132+
throw new UnsupportedOperationException("It looks like neither the deprecated \"validateRequestInternal\"" +
133+
"nor its replacement (this method) are implemented.");
138134
}
139135

140136
@Override
@@ -197,15 +193,13 @@ protected static class RequestExpectationGroup {
197193

198194
private final Set<RequestExpectation> expectations = new LinkedHashSet<>();
199195

200-
201-
public Set<RequestExpectation> getExpectations() {
202-
return this.expectations;
203-
}
204-
205196
public void addAllExpectations(Collection<RequestExpectation> expectations) {
206197
this.expectations.addAll(expectations);
207198
}
208199

200+
public Set<RequestExpectation> getExpectations() {
201+
return this.expectations;
202+
}
209203

210204
/**
211205
* Return a matching expectation, or {@code null} if none match.

spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,6 @@
4444
import org.springframework.http.HttpMethod;
4545
import org.springframework.lang.Nullable;
4646
import org.springframework.util.Assert;
47-
import org.springframework.web.util.NestedServletException;
4847

4948
/**
5049
* Adapt {@link HttpHandler} to an {@link HttpServlet} using Servlet Async
@@ -157,11 +156,9 @@ private String getServletPath(ServletConfig config) {
157156

158157
@Override
159158
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
160-
161159
if (DispatcherType.ASYNC.equals(request.getDispatcherType())) {
162160
Throwable ex = (Throwable) request.getAttribute(WRITE_ERROR_ATTRIBUTE_NAME);
163-
Assert.notNull(ex, "Unexpected async dispatch");
164-
throw new NestedServletException("Write publisher error", ex);
161+
throw new ServletException("Write publisher error", ex);
165162
}
166163

167164
// Start async before Read/WriteListener registration
@@ -230,7 +227,6 @@ private static class HandlerResultAsyncListener implements AsyncListener {
230227

231228
private final AtomicBoolean isCompleted;
232229

233-
234230
public HandlerResultAsyncListener(AtomicBoolean isCompleted) {
235231
this.isCompleted = isCompleted;
236232
}
@@ -267,7 +263,6 @@ private class HandlerResultSubscriber implements Subscriber<Void> {
267263

268264
private final AtomicBoolean isCompleted;
269265

270-
271266
public HandlerResultSubscriber(AsyncContext asyncContext, AtomicBoolean isCompleted) {
272267
this.asyncContext = asyncContext;
273268
this.isCompleted = isCompleted;

spring-web/src/main/java/org/springframework/web/cors/reactive/CorsUtils.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@
1919
import org.springframework.http.HttpHeaders;
2020
import org.springframework.http.HttpMethod;
2121
import org.springframework.http.server.reactive.ServerHttpRequest;
22+
import org.springframework.lang.Nullable;
2223
import org.springframework.util.Assert;
2324
import org.springframework.web.util.UriComponents;
2425
import org.springframework.web.util.UriComponentsBuilder;
2526

26-
;
27-
2827
/**
2928
* Utility class for CORS reactive request handling based on the
3029
* <a href="http://www.w3.org/TR/cors/">CORS W3C recommendation</a>.
@@ -71,7 +70,7 @@ public static boolean isSameOrigin(ServerHttpRequest request) {
7170
return (actualHost.equals(originUrl.getHost()) && actualPort == getPort(originUrl.getScheme(), originUrl.getPort()));
7271
}
7372

74-
private static int getPort(String scheme, int port) {
73+
private static int getPort(@Nullable String scheme, int port) {
7574
if (port == -1) {
7675
if ("http".equals(scheme) || "ws".equals(scheme)) {
7776
port = 80;

spring-web/src/main/java/org/springframework/web/util/WebUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -754,7 +754,7 @@ private static boolean containsForwardedHeaders(HttpServletRequest request) {
754754
return false;
755755
}
756756

757-
private static int getPort(String scheme, int port) {
757+
private static int getPort(@Nullable String scheme, int port) {
758758
if (port == -1) {
759759
if ("http".equals(scheme) || "ws".equals(scheme)) {
760760
port = 80;

0 commit comments

Comments
 (0)