From 53d044814fb2478d3583db21a51e0f1a902a83a8 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 3 Nov 2022 13:20:45 -0400 Subject: [PATCH] Fix AbstractMProducingHandler for ReactiveAdapter Turns out there is a reactive adapter for `CompletableFuture` which is not an intention of the further logic --- .../handler/AbstractMessageProducingHandler.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java index 76badb9bde..2e48a782d0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java @@ -310,11 +310,16 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan } if (this.async) { - ReactiveAdapter reactiveAdapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(null, reply); - if (reply instanceof org.springframework.util.concurrent.ListenableFuture - || reply instanceof CompletableFuture - || reactiveAdapter != null) { + boolean isFutureReply = + reply instanceof org.springframework.util.concurrent.ListenableFuture || + reply instanceof CompletableFuture; + ReactiveAdapter reactiveAdapter = null; + if (!isFutureReply) { + reactiveAdapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(null, reply); + } + + if (isFutureReply || reactiveAdapter != null) { if (replyChannel instanceof ReactiveStreamsSubscribableChannel reactiveStreamsSubscribableChannel) { Publisher reactiveReply = toPublisherReply(reply, reactiveAdapter); reactiveStreamsSubscribableChannel