GH-9618: Remove usage of ListenableFuture

Fixes: https://github.com/spring-projects/spring-integration/issues/9618
This commit is contained in:
Artem Bilan
2025-01-02 11:25:46 -05:00
parent 12ceaec096
commit 9d29bdf5b5
3 changed files with 10 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@@ -522,7 +522,6 @@ public class GatewayProxyFactoryBean<T> extends AbstractEndpoint
@Override
@Nullable
@SuppressWarnings("removal")
public Object invoke(final MethodInvocation invocation) throws Throwable { // NOSONAR
Method method = invocation.getMethod();
Class<?> returnType;
@@ -541,13 +540,6 @@ public class GatewayProxyFactoryBean<T> extends AbstractEndpoint
else if (CompletableFuture.class.equals(returnType)) { // exact
return CompletableFuture.supplyAsync(invoker, this.asyncExecutor);
}
else if (org.springframework.util.concurrent.ListenableFuture.class.equals(returnType)) {
logger.warn("The 'org.springframework.util.concurrent.ListenableFuture' is deprecated for removal." +
"The 'CompletableFuture' is recommended to be used instead." +
"The 'ListenableFuture' support will be removed in Spring Integration 6.5.");
return ((org.springframework.core.task.AsyncListenableTaskExecutor) this.asyncExecutor)
.submitListenable(invoker::get);
}
else if (Future.class.isAssignableFrom(returnType)) {
logger.debug(() -> "AsyncTaskExecutor submit*() return types are incompatible with the method return " +
"type; running on calling thread; the downstream flow must return the required Future: "

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2024 the original author or authors.
* Copyright 2014-2025 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.
@@ -321,7 +321,6 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
return replyChannel;
}
@SuppressWarnings("removal")
private void doProduceOutput(Message<?> requestMessage, MessageHeaders requestHeaders, Object reply,
@Nullable Object replyChannelArg) {
@@ -331,9 +330,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
}
if (this.async) {
boolean isFutureReply =
reply instanceof org.springframework.util.concurrent.ListenableFuture<?> ||
reply instanceof CompletableFuture<?>;
boolean isFutureReply = reply instanceof CompletableFuture<?>;
ReactiveAdapter reactiveAdapter = null;
if (!isFutureReply) {
@@ -366,7 +363,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
return reactiveAdapter.toPublisher(reply);
}
else {
return Mono.fromFuture(toCompletableFuture(reply));
return Mono.fromFuture((CompletableFuture<?>) reply);
}
}
@@ -415,20 +412,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
return replyFuture;
}
else {
return toCompletableFuture(reply);
}
}
@SuppressWarnings("removal")
private CompletableFuture<?> toCompletableFuture(Object reply) {
if (reply instanceof CompletableFuture<?> completableFuture) {
return completableFuture;
}
else {
logger.warn("The 'org.springframework.util.concurrent.ListenableFuture' is deprecated for removal." +
"The 'CompletableFuture' is recommended to be used instead." +
"The 'ListenableFuture' support will be removed in Spring Integration 6.5.");
return ((org.springframework.util.concurrent.ListenableFuture<?>) reply).completable();
return (CompletableFuture<?>) reply;
}
}

View File

@@ -13,3 +13,8 @@ If you are interested in more details, see the Issue Tracker tickets that were r
In general the project has been moved to the latest dependency versions.
[[x6.5-general]]
== General Changes
The deprecated previously usage of `org.springframework.util.concurrent.ListenableFuture` has been removed in favor of `CompletableFuture`.