From a2fe78a9cdb9edbb2ac5fe6b3ebbd66ca87d7298 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 5 Oct 2022 17:00:59 +0200 Subject: [PATCH] GH-2522 polishing previous commit --- .../stream/binder/DefaultBinderFactory.java | 22 ------------------- .../SpelExpressionConverterConfiguration.java | 11 ++++++++-- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java index 8786a0331..ac0326dfe 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java @@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.cloud.function.context.FunctionCatalog; import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry; -import org.springframework.cloud.stream.config.ListenerContainerCustomizer; import org.springframework.cloud.stream.reflection.GenericsUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -413,27 +412,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl } else if (this.context != null) { this.propagateSharedBeans(binderProducingContext); - Map customizers = this.context.getBeansOfType(ListenerContainerCustomizer.class); - if (!CollectionUtils.isEmpty(customizers)) { - for (Entry customizerEntry : customizers.entrySet()) { - ListenerContainerCustomizer customizerWrapper = new ListenerContainerCustomizer() { - @SuppressWarnings("unchecked") - @Override - public void configure(Object container, String destinationName, String group) { - try { - customizerEntry.getValue().configure(container, destinationName, group); - } - catch (Exception e) { - logger.warn("Failed while applying ListenerContainerCustomizer. In situations when multiple " - + "binders are used this is expected, since a particular customizer may not be applicable."); - } - } - }; - - ((GenericApplicationContext) binderProducingContext).registerBean(customizerEntry.getKey(), - ListenerContainerCustomizer.class, () -> customizerWrapper); - } - } binderProducingContext.addApplicationListener(new ApplicationListener() { @Override public void onApplicationEvent(ApplicationEvent event) { diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/SpelExpressionConverterConfiguration.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/SpelExpressionConverterConfiguration.java index 9f1a600a2..4b90f7680 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/SpelExpressionConverterConfiguration.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/SpelExpressionConverterConfiguration.java @@ -22,11 +22,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Role; import org.springframework.core.convert.converter.Converter; +import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.ParseException; @@ -67,8 +69,13 @@ public class SpelExpressionConverterConfiguration { @Bean @ConfigurationPropertiesBinding @IntegrationConverter - public Converter spelConverter() { - return new SpelConverter(); + public Converter spelConverter(ConfigurableApplicationContext context) { + SpelConverter converter = new SpelConverter(); + ConfigurableConversionService cs = (ConfigurableConversionService) context.getBeanFactory().getConversionService(); + if (cs != null) { + cs.addConverter(converter); + } + return converter; } /**