Remove APIs marked as deprecated for removal
Closes gh-33809
This commit is contained in:
@@ -50,35 +50,6 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
|
||||
*/
|
||||
boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType);
|
||||
|
||||
/**
|
||||
* Adapt the asynchronous return value to a
|
||||
* {@link org.springframework.util.concurrent.ListenableFuture ListenableFuture}.
|
||||
* <p>Implementations should consider returning an instance of
|
||||
* {@link org.springframework.util.concurrent.SettableListenableFuture
|
||||
* SettableListenableFuture}. Return value handling will then continue when
|
||||
* the ListenableFuture is completed with either success or error.
|
||||
* <p><strong>Note:</strong> this method will only be invoked after
|
||||
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
|
||||
* is called and it returns {@code true}.
|
||||
* @param returnValue the value returned from the handler method
|
||||
* @param returnType the type of the return value
|
||||
* @return the resulting ListenableFuture, or {@code null} in which case
|
||||
* no further handling will be performed
|
||||
* @deprecated as of 6.0, in favor of
|
||||
* {@link #toCompletableFuture(Object, MethodParameter)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
@Nullable
|
||||
default org.springframework.util.concurrent.ListenableFuture<?> toListenableFuture(
|
||||
Object returnValue, MethodParameter returnType) {
|
||||
|
||||
CompletableFuture<?> result = toCompletableFuture(returnValue, returnType);
|
||||
return (result != null ?
|
||||
new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(result) :
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the asynchronous return value to a {@link CompletableFuture}.
|
||||
* <p>Return value handling will then continue when
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.invocation;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
|
||||
/**
|
||||
* Support for {@link org.springframework.util.concurrent.ListenableFuture} as a return value type.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 4.2
|
||||
* @deprecated as of 6.0, in favor of {@link CompletableFutureReturnValueHandler}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public class ListenableFutureReturnValueHandler extends AbstractAsyncReturnValueHandler {
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return org.springframework.util.concurrent.ListenableFuture.class.isAssignableFrom(returnType.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.springframework.util.concurrent.ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType) {
|
||||
return (org.springframework.util.concurrent.ListenableFuture<?>) returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> toCompletableFuture(Object returnValue, MethodParameter returnType) {
|
||||
return ((org.springframework.util.concurrent.ListenableFuture<?>) returnValue).completable();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -344,13 +344,11 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() {
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>();
|
||||
|
||||
// Single-purpose return value types
|
||||
|
||||
handlers.add(new org.springframework.messaging.handler.invocation.ListenableFutureReturnValueHandler());
|
||||
handlers.add(new CompletableFutureReturnValueHandler());
|
||||
if (reactorPresent) {
|
||||
handlers.add(new ReactiveReturnValueHandler());
|
||||
|
||||
@@ -31,17 +31,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
*/
|
||||
public interface ConnectionHandlingStompSession extends StompSession, StompTcpConnectionHandler<byte[]> {
|
||||
|
||||
/**
|
||||
* Return a future that will complete when the session is ready for use.
|
||||
* @deprecated as of 6.0, in favor of {@link #getSession()}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
default org.springframework.util.concurrent.ListenableFuture<StompSession> getSessionFuture() {
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
|
||||
getSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a future that will complete when the session is ready for use.
|
||||
* @since 6.0
|
||||
|
||||
@@ -89,22 +89,6 @@ public class ReactorNettyTcpStompClient extends StompClientSupport {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Connect and notify the given {@link StompSessionHandler} when connected
|
||||
* on the STOMP level.
|
||||
* @param handler the handler for the STOMP session
|
||||
* @return a ListenableFuture for access to the session when ready for use
|
||||
* @deprecated as of 6.0, in favor of {@link #connectAsync(StompSessionHandler)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
|
||||
StompSessionHandler handler) {
|
||||
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
|
||||
connectAsync(handler));
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect and notify the given {@link StompSessionHandler} when connected
|
||||
* on the STOMP level.
|
||||
@@ -116,24 +100,6 @@ public class ReactorNettyTcpStompClient extends StompClientSupport {
|
||||
return connectAsync(null, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* An overloaded version of {@link #connect(StompSessionHandler)} that
|
||||
* accepts headers to use for the STOMP CONNECT frame.
|
||||
* @param connectHeaders headers to add to the CONNECT frame
|
||||
* @param handler the handler for the STOMP session
|
||||
* @return a ListenableFuture for access to the session when ready for use
|
||||
* @deprecated as of 6.0, in favor of {@link #connectAsync(StompHeaders, StompSessionHandler)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
|
||||
@Nullable StompHeaders connectHeaders, StompSessionHandler handler) {
|
||||
|
||||
ConnectionHandlingStompSession session = createSession(connectHeaders, handler);
|
||||
this.tcpClient.connectAsync(session);
|
||||
return session.getSessionFuture();
|
||||
}
|
||||
|
||||
/**
|
||||
* An overloaded version of {@link #connectAsync(StompSessionHandler)} that
|
||||
* accepts headers to use for the STOMP CONNECT frame.
|
||||
|
||||
@@ -30,20 +30,6 @@ import org.springframework.messaging.Message;
|
||||
*/
|
||||
public interface TcpConnection<P> extends Closeable {
|
||||
|
||||
/**
|
||||
* Send the given message.
|
||||
* @param message the message
|
||||
* @return a ListenableFuture that can be used to determine when and if the
|
||||
* message was successfully sent
|
||||
* @deprecated as of 6.0, in favor of {@link #sendAsync(Message)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
default org.springframework.util.concurrent.ListenableFuture<Void> send(Message<P> message) {
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
|
||||
sendAsync(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given message.
|
||||
* @param message the message
|
||||
|
||||
@@ -27,22 +27,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
*/
|
||||
public interface TcpOperations<P> {
|
||||
|
||||
/**
|
||||
* Open a new connection.
|
||||
* @param connectionHandler a handler to manage the connection
|
||||
* @return a ListenableFuture that can be used to determine when and if the
|
||||
* connection is successfully established
|
||||
* @deprecated as of 6.0, in favor of {@link #connectAsync(TcpConnectionHandler)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
default org.springframework.util.concurrent.ListenableFuture<Void> connect(
|
||||
TcpConnectionHandler<P> connectionHandler) {
|
||||
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
|
||||
connectAsync(connectionHandler));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a new connection.
|
||||
* @param connectionHandler a handler to manage the connection
|
||||
@@ -52,23 +36,6 @@ public interface TcpOperations<P> {
|
||||
*/
|
||||
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler);
|
||||
|
||||
/**
|
||||
* Open a new connection and a strategy for reconnecting if the connection fails.
|
||||
* @param connectionHandler a handler to manage the connection
|
||||
* @param reconnectStrategy a strategy for reconnecting
|
||||
* @return a ListenableFuture that can be used to determine when and if the
|
||||
* initial connection is successfully established
|
||||
* @deprecated as of 6.0, in favor of {@link #connectAsync(TcpConnectionHandler, ReconnectStrategy)}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
default org.springframework.util.concurrent.ListenableFuture<Void> connect(
|
||||
TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy) {
|
||||
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
|
||||
connectAsync(connectionHandler, reconnectStrategy));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a new connection and a strategy for reconnecting if the connection fails.
|
||||
* @param connectionHandler a handler to manage the connection
|
||||
@@ -79,18 +46,6 @@ public interface TcpOperations<P> {
|
||||
*/
|
||||
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
|
||||
|
||||
/**
|
||||
* Shut down and close any open connections.
|
||||
* @return a ListenableFuture that can be used to determine when and if the
|
||||
* connection is successfully closed
|
||||
* @deprecated as of 6.0, in favor of {@link #shutdownAsync()}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
default org.springframework.util.concurrent.ListenableFuture<Void> shutdown() {
|
||||
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(shutdownAsync());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shut down and close any open connections.
|
||||
* @return a CompletableFuture that can be used to determine when and if the
|
||||
|
||||
@@ -273,39 +273,6 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
assertThat(controller.method).isEqualTo("handleFoo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void listenableFutureSuccess() {
|
||||
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
given(this.channel.send(any(Message.class))).willReturn(true);
|
||||
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
|
||||
|
||||
ListenableFutureController controller = new ListenableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
||||
Message<?> message = createMessage("/app1/listenable-future/success");
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
||||
assertThat(controller.future).isNotNull();
|
||||
controller.future.run();
|
||||
verify(this.converter).toMessage(this.payloadCaptor.capture(), any(MessageHeaders.class));
|
||||
assertThat(this.payloadCaptor.getValue()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listenableFutureFailure() {
|
||||
ListenableFutureController controller = new ListenableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
||||
Message<?> message = createMessage("/app1/listenable-future/failure");
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
||||
controller.future.run();
|
||||
assertThat(controller.exceptionCaught).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void completableFutureSuccess() {
|
||||
@@ -569,36 +536,6 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
@MessageMapping("listenable-future")
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
private static class ListenableFutureController {
|
||||
|
||||
org.springframework.util.concurrent.ListenableFutureTask<String> future;
|
||||
|
||||
boolean exceptionCaught = false;
|
||||
|
||||
@MessageMapping("success")
|
||||
public org.springframework.util.concurrent.ListenableFutureTask<String> handleListenableFuture() {
|
||||
this.future = new org.springframework.util.concurrent.ListenableFutureTask<>(() -> "foo");
|
||||
return this.future;
|
||||
}
|
||||
|
||||
@MessageMapping("failure")
|
||||
public org.springframework.util.concurrent.ListenableFutureTask<String> handleListenableFutureException() {
|
||||
this.future = new org.springframework.util.concurrent.ListenableFutureTask<>(() -> {
|
||||
throw new IllegalStateException();
|
||||
});
|
||||
return this.future;
|
||||
}
|
||||
|
||||
@MessageExceptionHandler(IllegalStateException.class)
|
||||
public void handleValidationException() {
|
||||
this.exceptionCaught = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
private static class CompletableFutureController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user