Browse Source

Polishing

(cherry picked from commit edf7f3cd43)
6.1.x
Juergen Hoeller 1 year ago
parent
commit
aaf2e8fbe6
  1. 14
      spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java
  2. 6
      spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java
  3. 12
      spring-web/src/main/java/org/springframework/http/MediaType.java
  4. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultAsyncServerResponse.java
  5. 2
      spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java
  6. 6
      spring-websocket/spring-websocket.gradle
  7. 2
      spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java
  8. 3
      spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java
  9. 12
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java
  10. 3
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java

14
spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java

@ -209,18 +209,10 @@ abstract class AbstractSchedulingTaskExecutorTests { @@ -209,18 +209,10 @@ abstract class AbstractSchedulingTaskExecutorTests {
CompletableFuture<?> future1 = executor.submitCompletable(new TestTask(this.testName, -1));
CompletableFuture<?> future2 = executor.submitCompletable(new TestTask(this.testName, -1));
shutdownExecutor();
try {
assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> {
future1.get(1000, TimeUnit.MILLISECONDS);
}
catch (Exception ex) {
// ignore
}
Awaitility.await()
.atMost(5, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> assertThatExceptionOfType(TimeoutException.class)
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
future2.get(1000, TimeUnit.MILLISECONDS);
});
}
@Test

6
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java

@ -182,10 +182,10 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen @@ -182,10 +182,10 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
@Override
public void processAheadOfTime(RuntimeHints runtimeHints, Class<?> testClass, ClassLoader classLoader) {
getSqlAnnotationsFor(testClass).forEach(sql ->
registerClasspathResources(getScripts(sql, testClass, null, true), runtimeHints, classLoader));
registerClasspathResources(getScripts(sql, testClass, null, true), runtimeHints, classLoader));
getSqlMethods(testClass).forEach(testMethod ->
getSqlAnnotationsFor(testMethod).forEach(sql ->
registerClasspathResources(getScripts(sql, testClass, testMethod, false), runtimeHints, classLoader)));
getSqlAnnotationsFor(testMethod).forEach(sql ->
registerClasspathResources(getScripts(sql, testClass, testMethod, false), runtimeHints, classLoader)));
}
/**

12
spring-web/src/main/java/org/springframework/http/MediaType.java

@ -853,7 +853,7 @@ public class MediaType extends MimeType implements Serializable { @@ -853,7 +853,7 @@ public class MediaType extends MimeType implements Serializable {
* <blockquote>audio/basic == text/html</blockquote>
* <blockquote>audio/basic == audio/wave</blockquote>
* @param mediaTypes the list of media types to be sorted
* @deprecated As of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)}
* @deprecated as of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)}
*/
@Deprecated(since = "6.0", forRemoval = true)
public static void sortBySpecificity(List<MediaType> mediaTypes) {
@ -882,7 +882,7 @@ public class MediaType extends MimeType implements Serializable { @@ -882,7 +882,7 @@ public class MediaType extends MimeType implements Serializable {
* </ol>
* @param mediaTypes the list of media types to be sorted
* @see #getQualityValue()
* @deprecated As of 6.0, with no direct replacement
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated(since = "6.0", forRemoval = true)
public static void sortByQualityValue(List<MediaType> mediaTypes) {
@ -895,9 +895,9 @@ public class MediaType extends MimeType implements Serializable { @@ -895,9 +895,9 @@ public class MediaType extends MimeType implements Serializable {
/**
* Sorts the given list of {@code MediaType} objects by specificity as the
* primary criteria and quality value the secondary.
* @deprecated As of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)}
* @deprecated as of 6.0, in favor of {@link MimeTypeUtils#sortBySpecificity(List)}
*/
@Deprecated(since = "6.0")
@Deprecated(since = "6.0", forRemoval = true)
public static void sortBySpecificityAndQuality(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) {
@ -908,7 +908,7 @@ public class MediaType extends MimeType implements Serializable { @@ -908,7 +908,7 @@ public class MediaType extends MimeType implements Serializable {
/**
* Comparator used by {@link #sortByQualityValue(List)}.
* @deprecated As of 6.0, with no direct replacement
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated(since = "6.0", forRemoval = true)
public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> {
@ -948,7 +948,7 @@ public class MediaType extends MimeType implements Serializable { @@ -948,7 +948,7 @@ public class MediaType extends MimeType implements Serializable {
/**
* Comparator used by {@link #sortBySpecificity(List)}.
* @deprecated As of 6.0, with no direct replacement
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")

5
spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultAsyncServerResponse.java

@ -67,6 +67,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple @@ -67,6 +67,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
this.timeout = timeout;
}
@Override
public ServerResponse block() {
try {
@ -114,8 +115,8 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple @@ -114,8 +115,8 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
}
}
@Nullable
@Override
@Nullable
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
throws ServletException, IOException {
@ -169,6 +170,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple @@ -169,6 +170,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
return result;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public static AsyncServerResponse create(Object obj, @Nullable Duration timeout) {
Assert.notNull(obj, "Argument to async must not be null");
@ -192,5 +194,4 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple @@ -192,5 +194,4 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
throw new IllegalArgumentException("Asynchronous type not supported: " + obj.getClass());
}
}

2
spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java

@ -54,6 +54,7 @@ class DefaultServerResponseBuilderTests { @@ -54,6 +54,7 @@ class DefaultServerResponseBuilderTests {
static final ServerResponse.Context EMPTY_CONTEXT = Collections::emptyList;
@Test
@SuppressWarnings("removal")
void status() {
@ -75,7 +76,6 @@ class DefaultServerResponseBuilderTests { @@ -75,7 +76,6 @@ class DefaultServerResponseBuilderTests {
assertThat(result.cookies().getFirst("foo")).isEqualTo(cookie);
}
@Test
void ok() {
ServerResponse response = ServerResponse.ok().build();

6
spring-websocket/spring-websocket.gradle

@ -16,13 +16,13 @@ dependencies { @@ -16,13 +16,13 @@ dependencies {
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"
}
optional("org.eclipse.jetty.ee10:jetty-ee10-webapp") {
exclude group: "jakarta.servlet", module: "jakarta.servlet-api"
}
optional("org.eclipse.jetty.ee10.websocket:jetty-ee10-websocket-jakarta-server")
optional("org.eclipse.jetty.ee10.websocket:jetty-ee10-websocket-jetty-server") {
exclude group: "jakarta.servlet", module: "jakarta.servlet-api"
}
optional("org.eclipse.jetty.ee10:jetty-ee10-webapp") {
exclude group: "jakarta.servlet", module: "jakarta.servlet-api"
}
optional("org.glassfish.tyrus:tyrus-container-servlet")
testImplementation(testFixtures(project(":spring-core")))
testImplementation(testFixtures(project(":spring-web")))

2
spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java

@ -34,12 +34,10 @@ import org.springframework.web.socket.WebSocketExtension; @@ -34,12 +34,10 @@ import org.springframework.web.socket.WebSocketExtension;
*/
public class StandardToWebSocketExtensionAdapter extends WebSocketExtension {
public StandardToWebSocketExtensionAdapter(Extension extension) {
super(extension.getName(), initParameters(extension));
}
private static Map<String, String> initParameters(Extension extension) {
List<Extension.Parameter> parameters = extension.getParameters();
Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT);

3
spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2024 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.
@ -55,6 +55,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension { @@ -55,6 +55,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension {
}
}
@Override
public String getName() {
return this.name;

12
spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java

@ -234,7 +234,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -234,7 +234,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
@ -254,7 +254,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -254,7 +254,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
@ -271,7 +271,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -271,7 +271,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
@ -293,7 +293,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -293,7 +293,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
@ -314,7 +314,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -314,7 +314,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* {@link #connectAsync(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
@ -334,7 +334,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -334,7 +334,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* {@link #connectAsync(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake

3
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -278,6 +278,7 @@ class DefaultTransportRequest implements TransportRequest { @@ -278,6 +278,7 @@ class DefaultTransportRequest implements TransportRequest {
}
}
/**
* Updates the given (global) future based success or failure to connect for
* the entire SockJS request regardless of which transport actually managed

Loading…
Cancel
Save