From 053563de54d4f392183d7ccba3c6a13ea90189a2 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 4 Oct 2022 20:29:10 +0200 Subject: [PATCH] GH-2283 Fix binder specific 'default' bindings Resolves #2283 --- .../stream/binder/AbstractExtendedBindingProperties.java | 8 +++----- .../cloud/stream/binder/DefaultBinderFactory.java | 9 ++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java index e9e9b1870..a4bb0d0ae 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractExtendedBindingProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericApplicationContext; -import org.springframework.integration.support.utils.IntegrationUtils; - /** * Base implementation of {@link ExtendedBindingProperties}. * @@ -90,9 +88,9 @@ public abstract class AbstractExtendedBindingProperties binderProperties, BinderType binderType, BinderConfiguration binderConfiguration, boolean refresh) { AnnotationConfigApplicationContext binderProducingContext = new AnnotationConfigApplicationContext(); - + if (this.context != null) { + binderProducingContext.getBeanFactory().setConversionService(this.context.getBeanFactory().getConversionService()); + GenericConversionService cs = (GenericConversionService) ((GenericApplicationContext) binderProducingContext).getBeanFactory().getConversionService(); + SpelConverter spelConverter = new SpelConverter(); + cs.addConverter(spelConverter); + } List sourceClasses = new ArrayList<>(); sourceClasses.addAll(Arrays.asList(binderType.getConfigurationClasses())); sourceClasses.addAll(Collections.singletonList(SpelExpressionConverterConfiguration.class));