From 476bb6d31e8bacfd196085d779b000c76652aec2 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 8 Jan 2024 11:51:24 -0500 Subject: [PATCH] Fix SftpSupplier bean naming race condition Since we create several `MessageSource` bean in the configuration it is better to be more specific with their injection via `@Qualifier` --- .../supplier/sftp/SftpSupplierConfiguration.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/supplier/spring-sftp-supplier/src/main/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierConfiguration.java b/supplier/spring-sftp-supplier/src/main/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierConfiguration.java index e7447b6a..240d0cb3 100644 --- a/supplier/spring-sftp-supplier/src/main/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierConfiguration.java +++ b/supplier/spring-sftp-supplier/src/main/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierConfiguration.java @@ -100,7 +100,8 @@ public class SftpSupplierConfiguration { private static final String FILE_MODIFIED_TIME_HEADER = "FILE_MODIFIED_TIME"; @Bean - public Supplier>> sftpSupplier(MessageSource sftpMessageSource, + public Supplier>> sftpSupplier( + @Qualifier("sftpMessageSource") MessageSource sftpMessageSource, @Nullable Publisher> sftpReadingFlow, SftpSupplierProperties sftpSupplierProperties) { Flux> flux = (sftpReadingFlow != null) ? Flux.from(sftpReadingFlow) @@ -115,8 +116,8 @@ public class SftpSupplierConfiguration { @Bean @Primary - public MessageSource sftpMessageSource(MessageSource messageSource, BeanFactory beanFactory, - @Nullable List receiveMessageAdvice) { + public MessageSource sftpMessageSource(@Qualifier("targetMessageSource") MessageSource messageSource, + BeanFactory beanFactory, @Nullable List receiveMessageAdvice) { if (CollectionUtils.isEmpty(receiveMessageAdvice)) { return messageSource; @@ -157,7 +158,8 @@ public class SftpSupplierConfiguration { /* * Create a Flux from a MessageSource that will be used by the supplier. */ - private Flux> sftpMessageFlux(MessageSource sftpMessageSource, + private Flux> sftpMessageFlux( + @Qualifier("sftpMessageSource") MessageSource sftpMessageSource, SftpSupplierProperties sftpSupplierProperties) { return IntegrationReactiveUtils.messageSourceToFlux(sftpMessageSource) @@ -201,7 +203,7 @@ public class SftpSupplierConfiguration { } @Bean - Publisher> sftpReadingFlow(MessageSource sftpMessageSource, + Publisher> sftpReadingFlow(@Qualifier("sftpMessageSource") MessageSource sftpMessageSource, SftpSupplierProperties sftpSupplierProperties, FileConsumerProperties fileConsumerProperties) { return FileUtils @@ -247,7 +249,7 @@ public class SftpSupplierConfiguration { */ @Bean @ConditionalOnExpression("environment['file.consumer.mode']!='ref' && environment['sftp.supplier.list-only']!='true'") - Publisher> sftpReadingFlow(MessageSource sftpMessageSource, + Publisher> sftpReadingFlow(@Qualifier("sftpMessageSource") MessageSource sftpMessageSource, SftpSupplierProperties sftpSupplierProperties, FileConsumerProperties fileConsumerProperties, @Nullable @Qualifier("renameRemoteFileHandler") MessageHandler renameRemoteFileHandler) {