Skip to content

Commit 070d186

Browse files
committed
use CompleteToListeFutureAdapter in TcpOutGateway
The `TcpOutboundGateway` deals internally with a `CompletableFuture`. However, the `AbstractMessageProducingHandler` cannot handle them until `6.0`. * Use `CompletableToListenableFutureAdapter` to produce a reply from `TcpOutboundGateway` which can be handled properly in the `AbstractMessageProducingHandler`
1 parent 1aef041 commit 070d186

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpOutboundGateway.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import org.springframework.messaging.MessagingException;
5151
import org.springframework.messaging.support.ErrorMessage;
5252
import org.springframework.util.Assert;
53-
import org.springframework.util.concurrent.SettableListenableFuture;
53+
import org.springframework.util.concurrent.CompletableToListenableFutureAdapter;
5454

5555
/**
5656
* TCP outbound gateway that uses a client connection factory. If the factory is configured
@@ -239,7 +239,7 @@ protected Object handleRequestMessage(Message<?> requestMessage) {
239239
connection.shutdownOutput();
240240
}
241241
if (async) {
242-
return reply.getFuture();
242+
return new CompletableToListenableFutureAdapter<>(reply.getFuture());
243243
}
244244
else {
245245
return getReply(requestMessage, connection, connectionId, reply);
@@ -353,7 +353,7 @@ public boolean onMessage(Message<?> message) {
353353
}
354354
}
355355
if (isAsync()) {
356-
reply.getFuture().set(message);
356+
reply.getFuture().complete(message);
357357
cleanUp(reply.isHaveSemaphore(), reply.getConnection(), connectionId);
358358
}
359359
else {
@@ -524,7 +524,7 @@ Message<?> getReply() {
524524
return this.reply;
525525
}
526526

527-
SettableListenableFuture<Message<?>> getFuture() {
527+
CompletableFuture<Message<?>> getFuture() {
528528
return this.future;
529529
}
530530

0 commit comments

Comments
 (0)