Skip to content

Commit 9d29bdf

Browse files
committed
GH-9618: Remove usage of ListenableFuture
Fixes: #9618
1 parent 12ceaec commit 9d29bdf

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -522,7 +522,6 @@ public T getObject() {
522522

523523
@Override
524524
@Nullable
525-
@SuppressWarnings("removal")
526525
public Object invoke(final MethodInvocation invocation) throws Throwable { // NOSONAR
527526
Method method = invocation.getMethod();
528527
Class<?> returnType;
@@ -541,13 +540,6 @@ public Object invoke(final MethodInvocation invocation) throws Throwable { // NO
541540
else if (CompletableFuture.class.equals(returnType)) { // exact
542541
return CompletableFuture.supplyAsync(invoker, this.asyncExecutor);
543542
}
544-
else if (org.springframework.util.concurrent.ListenableFuture.class.equals(returnType)) {
545-
logger.warn("The 'org.springframework.util.concurrent.ListenableFuture' is deprecated for removal." +
546-
"The 'CompletableFuture' is recommended to be used instead." +
547-
"The 'ListenableFuture' support will be removed in Spring Integration 6.5.");
548-
return ((org.springframework.core.task.AsyncListenableTaskExecutor) this.asyncExecutor)
549-
.submitListenable(invoker::get);
550-
}
551543
else if (Future.class.isAssignableFrom(returnType)) {
552544
logger.debug(() -> "AsyncTaskExecutor submit*() return types are incompatible with the method return " +
553545
"type; running on calling thread; the downstream flow must return the required Future: "

spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2024 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -321,7 +321,6 @@ else if (reply instanceof AbstractIntegrationMessageBuilder<?>) {
321321
return replyChannel;
322322
}
323323

324-
@SuppressWarnings("removal")
325324
private void doProduceOutput(Message<?> requestMessage, MessageHeaders requestHeaders, Object reply,
326325
@Nullable Object replyChannelArg) {
327326

@@ -331,9 +330,7 @@ private void doProduceOutput(Message<?> requestMessage, MessageHeaders requestHe
331330
}
332331

333332
if (this.async) {
334-
boolean isFutureReply =
335-
reply instanceof org.springframework.util.concurrent.ListenableFuture<?> ||
336-
reply instanceof CompletableFuture<?>;
333+
boolean isFutureReply = reply instanceof CompletableFuture<?>;
337334

338335
ReactiveAdapter reactiveAdapter = null;
339336
if (!isFutureReply) {
@@ -366,7 +363,7 @@ private Publisher<?> toPublisherReply(Object reply, @Nullable ReactiveAdapter re
366363
return reactiveAdapter.toPublisher(reply);
367364
}
368365
else {
369-
return Mono.fromFuture(toCompletableFuture(reply));
366+
return Mono.fromFuture((CompletableFuture<?>) reply);
370367
}
371368
}
372369

@@ -415,20 +412,7 @@ via whenComplete() callback. So, when value is set into the Future, it is availa
415412
return replyFuture;
416413
}
417414
else {
418-
return toCompletableFuture(reply);
419-
}
420-
}
421-
422-
@SuppressWarnings("removal")
423-
private CompletableFuture<?> toCompletableFuture(Object reply) {
424-
if (reply instanceof CompletableFuture<?> completableFuture) {
425-
return completableFuture;
426-
}
427-
else {
428-
logger.warn("The 'org.springframework.util.concurrent.ListenableFuture' is deprecated for removal." +
429-
"The 'CompletableFuture' is recommended to be used instead." +
430-
"The 'ListenableFuture' support will be removed in Spring Integration 6.5.");
431-
return ((org.springframework.util.concurrent.ListenableFuture<?>) reply).completable();
415+
return (CompletableFuture<?>) reply;
432416
}
433417
}
434418

src/reference/antora/modules/ROOT/pages/whats-new.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ If you are interested in more details, see the Issue Tracker tickets that were r
1313

1414
In general the project has been moved to the latest dependency versions.
1515

16+
[[x6.5-general]]
17+
== General Changes
18+
19+
The deprecated previously usage of `org.springframework.util.concurrent.ListenableFuture` has been removed in favor of `CompletableFuture`.
20+

0 commit comments

Comments
 (0)