Skip to content

Commit

Permalink
Adapt to deprecations in Spring Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Jul 27, 2022
1 parent ac12035 commit aac3ccf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +38,6 @@
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;
Expand Down Expand Up @@ -213,7 +213,7 @@ static class TestBean {

@Async
Future<String> echo(String text) {
return new AsyncResult<>(Thread.currentThread().getName() + " " + text);
return CompletableFuture.completedFuture(Thread.currentThread().getName() + " " + text);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void handleTransportError(StompSession session, Throwable exception) {
};

stompClient.setMessageConverter(new SimpleMessageConverter());
stompClient.connect("ws:https://localhost:{port}/messaging", handler, this.context.getWebServer().getPort());
stompClient.connectAsync("ws:https://localhost:{port}/messaging", handler, this.context.getWebServer().getPort());

if (!latch.await(30, TimeUnit.SECONDS)) {
if (failure.get() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;
Expand All @@ -50,7 +51,6 @@
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;
Expand Down Expand Up @@ -165,7 +165,7 @@ private LiveReloadWebSocketHandler connect(Function<WebSocketContainer, WebSocke
WsWebSocketContainer webSocketContainer = new WsWebSocketContainer();
WebSocketClient client = clientFactory.apply(webSocketContainer);
LiveReloadWebSocketHandler handler = new LiveReloadWebSocketHandler();
client.doHandshake(handler, "ws:https://localhost:" + this.port + "/livereload");
client.execute(handler, "ws:https://localhost:" + this.port + "/livereload");
handler.awaitHello();
return handler;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ static class UppercaseWebSocketClient extends StandardWebSocketClient {
}

@Override
protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler,
protected CompletableFuture<WebSocketSession> executeInternal(WebSocketHandler webSocketHandler,
HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions,
Map<String, Object> attributes) {
InetSocketAddress localAddress = new InetSocketAddress(getLocalHost(), uri.getPort());
Expand All @@ -311,7 +311,7 @@ protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandle
this.webSocketContainer.connectToServer(endpoint, endpointConfig, uri);
return session;
};
return getTaskExecutor().submitListenable(connectTask);
return getTaskExecutor().submitCompletable(connectTask);
}

private InetAddress getLocalHost() {
Expand Down

0 comments on commit aac3ccf

Please sign in to comment.