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 {
CompletableFuture<?> future1 = executor.submitCompletable(new TestTask(this.testName, -1)); CompletableFuture<?> future1 = executor.submitCompletable(new TestTask(this.testName, -1));
CompletableFuture<?> future2 = executor.submitCompletable(new TestTask(this.testName, -1)); CompletableFuture<?> future2 = executor.submitCompletable(new TestTask(this.testName, -1));
shutdownExecutor(); shutdownExecutor();
assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> {
try {
future1.get(1000, TimeUnit.MILLISECONDS); future1.get(1000, TimeUnit.MILLISECONDS);
} future2.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)));
} }
@Test @Test

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

@ -182,10 +182,10 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
@Override @Override
public void processAheadOfTime(RuntimeHints runtimeHints, Class<?> testClass, ClassLoader classLoader) { public void processAheadOfTime(RuntimeHints runtimeHints, Class<?> testClass, ClassLoader classLoader) {
getSqlAnnotationsFor(testClass).forEach(sql -> getSqlAnnotationsFor(testClass).forEach(sql ->
registerClasspathResources(getScripts(sql, testClass, null, true), runtimeHints, classLoader)); registerClasspathResources(getScripts(sql, testClass, null, true), runtimeHints, classLoader));
getSqlMethods(testClass).forEach(testMethod -> getSqlMethods(testClass).forEach(testMethod ->
getSqlAnnotationsFor(testMethod).forEach(sql -> getSqlAnnotationsFor(testMethod).forEach(sql ->
registerClasspathResources(getScripts(sql, testClass, testMethod, false), runtimeHints, classLoader))); 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 {
* <blockquote>audio/basic == text/html</blockquote> * <blockquote>audio/basic == text/html</blockquote>
* <blockquote>audio/basic == audio/wave</blockquote> * <blockquote>audio/basic == audio/wave</blockquote>
* @param mediaTypes the list of media types to be sorted * @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) @Deprecated(since = "6.0", forRemoval = true)
public static void sortBySpecificity(List<MediaType> mediaTypes) { public static void sortBySpecificity(List<MediaType> mediaTypes) {
@ -882,7 +882,7 @@ public class MediaType extends MimeType implements Serializable {
* </ol> * </ol>
* @param mediaTypes the list of media types to be sorted * @param mediaTypes the list of media types to be sorted
* @see #getQualityValue() * @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) @Deprecated(since = "6.0", forRemoval = true)
public static void sortByQualityValue(List<MediaType> mediaTypes) { public static void sortByQualityValue(List<MediaType> mediaTypes) {
@ -895,9 +895,9 @@ public class MediaType extends MimeType implements Serializable {
/** /**
* Sorts the given list of {@code MediaType} objects by specificity as the * Sorts the given list of {@code MediaType} objects by specificity as the
* primary criteria and quality value the secondary. * 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) { public static void sortBySpecificityAndQuality(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); Assert.notNull(mediaTypes, "'mediaTypes' must not be null");
if (mediaTypes.size() > 1) { if (mediaTypes.size() > 1) {
@ -908,7 +908,7 @@ public class MediaType extends MimeType implements Serializable {
/** /**
* Comparator used by {@link #sortByQualityValue(List)}. * 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) @Deprecated(since = "6.0", forRemoval = true)
public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> { public static final Comparator<MediaType> QUALITY_VALUE_COMPARATOR = (mediaType1, mediaType2) -> {
@ -948,7 +948,7 @@ public class MediaType extends MimeType implements Serializable {
/** /**
* Comparator used by {@link #sortBySpecificity(List)}. * 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) @Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal") @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
this.timeout = timeout; this.timeout = timeout;
} }
@Override @Override
public ServerResponse block() { public ServerResponse block() {
try { try {
@ -114,8 +115,8 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
} }
} }
@Nullable
@Override @Override
@Nullable
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context) public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)
throws ServletException, IOException { throws ServletException, IOException {
@ -169,6 +170,7 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
return result; return result;
} }
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public static AsyncServerResponse create(Object obj, @Nullable Duration timeout) { public static AsyncServerResponse create(Object obj, @Nullable Duration timeout) {
Assert.notNull(obj, "Argument to async must not be null"); Assert.notNull(obj, "Argument to async must not be null");
@ -192,5 +194,4 @@ final class DefaultAsyncServerResponse extends ErrorHandlingServerResponse imple
throw new IllegalArgumentException("Asynchronous type not supported: " + obj.getClass()); 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 {
static final ServerResponse.Context EMPTY_CONTEXT = Collections::emptyList; static final ServerResponse.Context EMPTY_CONTEXT = Collections::emptyList;
@Test @Test
@SuppressWarnings("removal") @SuppressWarnings("removal")
void status() { void status() {
@ -75,7 +76,6 @@ class DefaultServerResponseBuilderTests {
assertThat(result.cookies().getFirst("foo")).isEqualTo(cookie); assertThat(result.cookies().getFirst("foo")).isEqualTo(cookie);
} }
@Test @Test
void ok() { void ok() {
ServerResponse response = ServerResponse.ok().build(); ServerResponse response = ServerResponse.ok().build();

6
spring-websocket/spring-websocket.gradle

@ -16,13 +16,13 @@ dependencies {
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api" exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
exclude group: "org.apache.tomcat", module: "tomcat-websocket-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-jakarta-server")
optional("org.eclipse.jetty.ee10.websocket:jetty-ee10-websocket-jetty-server") { optional("org.eclipse.jetty.ee10.websocket:jetty-ee10-websocket-jetty-server") {
exclude group: "jakarta.servlet", module: "jakarta.servlet-api" 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") optional("org.glassfish.tyrus:tyrus-container-servlet")
testImplementation(testFixtures(project(":spring-core"))) testImplementation(testFixtures(project(":spring-core")))
testImplementation(testFixtures(project(":spring-web"))) 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;
*/ */
public class StandardToWebSocketExtensionAdapter extends WebSocketExtension { public class StandardToWebSocketExtensionAdapter extends WebSocketExtension {
public StandardToWebSocketExtensionAdapter(Extension extension) { public StandardToWebSocketExtensionAdapter(Extension extension) {
super(extension.getName(), initParameters(extension)); super(extension.getName(), initParameters(extension));
} }
private static Map<String, String> initParameters(Extension extension) { private static Map<String, String> initParameters(Extension extension) {
List<Extension.Parameter> parameters = extension.getParameters(); List<Extension.Parameter> parameters = extension.getParameters();
Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ROOT); 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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -55,6 +55,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension {
} }
} }
@Override @Override
public String getName() { public String getName() {
return this.name; 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
/** /**
* An overloaded version of * 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. * accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to * @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake * @param handshakeHeaders the headers for the WebSocket handshake
@ -254,7 +254,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/** /**
* An overloaded version of * 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. * accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to * @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake * @param handshakeHeaders the headers for the WebSocket handshake
@ -271,7 +271,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/** /**
* An overloaded version of * 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 WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame. * {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to * @param url the url to connect to
@ -293,7 +293,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/** /**
* An overloaded version of * 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 WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame. * {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to * @param url the url to connect to
@ -314,7 +314,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/** /**
* An overloaded version of * 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}. * that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to * @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake * @param handshakeHeaders the headers for the WebSocket handshake
@ -334,7 +334,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/** /**
* An overloaded version of * 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}. * that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to * @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake * @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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -278,6 +278,7 @@ class DefaultTransportRequest implements TransportRequest {
} }
} }
/** /**
* Updates the given (global) future based success or failure to connect for * Updates the given (global) future based success or failure to connect for
* the entire SockJS request regardless of which transport actually managed * the entire SockJS request regardless of which transport actually managed

Loading…
Cancel
Save