From a8dfb2f833854751f5434ec3f4b562cffaaa7a6f Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 4 Jan 2018 20:54:34 -0500 Subject: [PATCH] GH-1135 Fixed argument resolvers consistency - added SI provided argumentResolvers to MessageHandlerMethodFactory configuration to ensure that StreamListener annotated methods are consistent with equivalent SI config annotations (e.g., ServiceActivator) Resolves #1135 --- .../stream/config/BindingServiceConfiguration.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java index 282bf70d7..8bdf2530e 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java @@ -54,6 +54,7 @@ import org.springframework.context.annotation.Role; import org.springframework.expression.PropertyAccessor; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.PublishSubscribeChannel; +import org.springframework.integration.config.HandlerMethodArgumentResolversHolder; import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean; import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; @@ -96,17 +97,18 @@ public class BindingServiceConfiguration { private static final String ERROR_KEY_NAME = "error"; + @Bean public MessageChannelStreamListenerResultAdapter messageChannelStreamListenerResultAdapter() { return new MessageChannelStreamListenerResultAdapter(); } @Bean - public static MessageHandlerMethodFactory messageHandlerMethodFactory( - CompositeMessageConverterFactory compositeMessageConverterFactory) { + public static MessageHandlerMethodFactory messageHandlerMethodFactory(CompositeMessageConverterFactory compositeMessageConverterFactory, + @Qualifier(IntegrationContextUtils.ARGUMENT_RESOLVERS_BEAN_NAME) HandlerMethodArgumentResolversHolder ahmar) { DefaultMessageHandlerMethodFactory messageHandlerMethodFactory = new DefaultMessageHandlerMethodFactory(); - messageHandlerMethodFactory - .setMessageConverter(compositeMessageConverterFactory.getMessageConverterForAllRegistered()); + messageHandlerMethodFactory.setMessageConverter(compositeMessageConverterFactory.getMessageConverterForAllRegistered()); + messageHandlerMethodFactory.setCustomArgumentResolvers(ahmar.getResolvers()); return messageHandlerMethodFactory; } @@ -119,7 +121,7 @@ public class BindingServiceConfiguration { // This conditional is intentionally not in an autoconfig (usually a bad idea) because // it is used to detect a BindingService in the parent context (which we know // already exists). - @ConditionalOnMissingBean(BindingService.class) + @ConditionalOnMissingBean public BindingService bindingService(BindingServiceProperties bindingServiceProperties, BinderFactory binderFactory, TaskScheduler taskScheduler) { return new BindingService(bindingServiceProperties, binderFactory, taskScheduler);