From aac3ccf59c13f13c1e9739a13863b0193bc16875 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 27 Jul 2022 17:20:58 +0200 Subject: [PATCH] Adapt to deprecations in Spring Framework See https://github.com/spring-projects/spring-framework/issues/27780 --- .../task/TaskExecutionAutoConfigurationTests.java | 4 ++-- .../servlet/WebSocketMessagingAutoConfigurationTests.java | 2 +- .../boot/devtools/livereload/LiveReloadServerTests.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java index 5b1c97250b9..f9464241f9a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure.task; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.function.Consumer; @@ -37,7 +38,6 @@ import org.springframework.core.task.SyncTaskExecutor; import org.springframework.core.task.TaskDecorator; import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -213,7 +213,7 @@ class TaskExecutionAutoConfigurationTests { @Async Future echo(String text) { - return new AsyncResult<>(Thread.currentThread().getName() + " " + text); + return CompletableFuture.completedFuture(Thread.currentThread().getName() + " " + text); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java index 21019ab6932..c6332774566 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java @@ -192,7 +192,7 @@ class WebSocketMessagingAutoConfigurationTests { }; stompClient.setMessageConverter(new SimpleMessageConverter()); - stompClient.connect("ws://localhost:{port}/messaging", handler, this.context.getWebServer().getPort()); + stompClient.connectAsync("ws://localhost:{port}/messaging", handler, this.context.getWebServer().getPort()); if (!latch.await(30, TimeUnit.SECONDS)) { if (failure.get() != null) { diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java index c868c3872e1..7d86444bfee 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -50,7 +51,6 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; -import org.springframework.util.concurrent.ListenableFuture; import org.springframework.web.client.RestTemplate; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.PingMessage; @@ -165,7 +165,7 @@ class LiveReloadServerTests { WsWebSocketContainer webSocketContainer = new WsWebSocketContainer(); WebSocketClient client = clientFactory.apply(webSocketContainer); LiveReloadWebSocketHandler handler = new LiveReloadWebSocketHandler(); - client.doHandshake(handler, "ws://localhost:" + this.port + "/livereload"); + client.execute(handler, "ws://localhost:" + this.port + "/livereload"); handler.awaitHello(); return handler; } @@ -293,7 +293,7 @@ class LiveReloadServerTests { } @Override - protected ListenableFuture doHandshakeInternal(WebSocketHandler webSocketHandler, + protected CompletableFuture executeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List protocols, List extensions, Map attributes) { InetSocketAddress localAddress = new InetSocketAddress(getLocalHost(), uri.getPort()); @@ -311,7 +311,7 @@ class LiveReloadServerTests { this.webSocketContainer.connectToServer(endpoint, endpointConfig, uri); return session; }; - return getTaskExecutor().submitListenable(connectTask); + return getTaskExecutor().submitCompletable(connectTask); } private InetAddress getLocalHost() {