From 070d1868e59cbad73e798ffe33ec5bb48f4c07a1 Mon Sep 17 00:00:00 2001 From: abilan Date: Mon, 23 Jan 2023 11:35:23 -0500 Subject: [PATCH] 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` --- .../integration/ip/tcp/TcpOutboundGateway.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpOutboundGateway.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpOutboundGateway.java index 68e3851973..5ea53debc7 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpOutboundGateway.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/TcpOutboundGateway.java @@ -50,7 +50,7 @@ import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.ErrorMessage; import org.springframework.util.Assert; -import org.springframework.util.concurrent.SettableListenableFuture; +import org.springframework.util.concurrent.CompletableToListenableFutureAdapter; /** * TCP outbound gateway that uses a client connection factory. If the factory is configured @@ -239,7 +239,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler connection.shutdownOutput(); } if (async) { - return reply.getFuture(); + return new CompletableToListenableFutureAdapter<>(reply.getFuture()); } else { return getReply(requestMessage, connection, connectionId, reply); @@ -353,7 +353,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler } } if (isAsync()) { - reply.getFuture().set(message); + reply.getFuture().complete(message); cleanUp(reply.isHaveSemaphore(), reply.getConnection(), connectionId); } else { @@ -524,7 +524,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler return this.reply; } - SettableListenableFuture> getFuture() { + CompletableFuture> getFuture() { return this.future; }