From 5d9de8ad579d3464d1503d1a5d1390168bccbdb9 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 22 Feb 2021 15:31:54 +0100 Subject: [PATCH] GH-2115 Ensure outbound interceptor is not used for functional approach Resolves #2115 --- .../cloud/stream/binding/MessageConverterConfigurer.java | 9 +++------ .../stream/function/DynamicDestinationFunctionTests.java | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/MessageConverterConfigurer.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/MessageConverterConfigurer.java index 0dfe9b72c..6eb26d939 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/MessageConverterConfigurer.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/MessageConverterConfigurer.java @@ -155,13 +155,10 @@ public class MessageConverterConfigurer ConsumerProperties consumerProperties = bindingProperties.getConsumer(); if (this.isNativeEncodingNotSet(producerProperties, consumerProperties, inbound)) { if (inbound) { - messageChannel.addInterceptor( - new InboundContentTypeEnhancingInterceptor(contentType)); + messageChannel.addInterceptor(new InboundContentTypeEnhancingInterceptor(contentType)); } - else { - messageChannel.addInterceptor( - new OutboundContentTypeConvertingInterceptor(contentType, - this.compositeMessageConverter)); + else if (!functional) { + messageChannel.addInterceptor(new OutboundContentTypeConvertingInterceptor(contentType, this.compositeMessageConverter)); } } } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/DynamicDestinationFunctionTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/DynamicDestinationFunctionTests.java index 01cbded38..e9bc58f3d 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/DynamicDestinationFunctionTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/DynamicDestinationFunctionTests.java @@ -64,7 +64,8 @@ public class DynamicDestinationFunctionTests { serviceProperties.getProducerProperties("fooDestination").getPartitionKeyExtractorName()); OutputDestination output = context.getBean(OutputDestination.class); - assertThat(output.receive(1000).getPayload()).isEqualTo("fooDestination".getBytes()); + Object result = output.receive(1000).getPayload(); + assertThat(result).isEqualTo("fooDestination"); }); } @@ -88,7 +89,6 @@ public class DynamicDestinationFunctionTests { @Bean public Consumer cons() { return value -> { - System.out.println("Sending to " + value); resolver.resolveDestination(value).send(new GenericMessage(value)); }; }