diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java index e178c1355..bf60f3efb 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java @@ -231,10 +231,9 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl private void populateCandidatesForBindableType(Class bindingTargetType, List candidatesForBindableType, String defaultCandidateConfiguration) { // Going by the convention of proper reactor based binders start with the key literal - reactor - if (FluxMessageChannel.class.isAssignableFrom(bindingTargetType) && defaultCandidateConfiguration.startsWith("reactor")) { - candidatesForBindableType.add(defaultCandidateConfiguration); - } - else if (!defaultCandidateConfiguration.startsWith("reactor")) { + boolean isCandidate = (FluxMessageChannel.class.isAssignableFrom(bindingTargetType) && defaultCandidateConfiguration.startsWith("reactor")) + || !defaultCandidateConfiguration.startsWith("reactor"); + if (isCandidate) { candidatesForBindableType.add(defaultCandidateConfiguration); } } @@ -276,10 +275,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl ConfigurableApplicationContext binderProducingContext = this.initializeBinderContextSimple(configurationName, binderProperties, binderType, binderConfiguration); -// ConfigurableApplicationContext binderProducingContext = -// this.initializeBinderContextBoot(configurationName, binderProperties, binderType, binderConfiguration); - - Map messageConverters = binderProducingContext.getBeansOfType(MessageConverter.class); if (!CollectionUtils.isEmpty(messageConverters) && !ObjectUtils.isEmpty(context.getBeansOfType(FunctionCatalog.class))) { FunctionCatalog functionCatalog = this.context.getBean(FunctionCatalog.class); diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/FluxMessageChannelBindingTargetFactory.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/FluxMessageChannelBindingTargetFactory.java index a0990a3e4..28157cc71 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/FluxMessageChannelBindingTargetFactory.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/FluxMessageChannelBindingTargetFactory.java @@ -16,9 +16,9 @@ package org.springframework.cloud.stream.binding; -import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.GenericApplicationContext; import org.springframework.integration.channel.FluxMessageChannel; +import org.springframework.util.Assert; /** * @author Soby Chacko @@ -33,6 +33,7 @@ public class FluxMessageChannelBindingTargetFactory extends AbstractBindingTarge public FluxMessageChannelBindingTargetFactory(MessageChannelConfigurer messageChannelConfigurer, GenericApplicationContext context) { super(FluxMessageChannel.class); + Assert.notNull(context, "'context' must not be null"); this.messageChannelConfigurer = messageChannelConfigurer; this.context = context; } @@ -53,20 +54,13 @@ public class FluxMessageChannelBindingTargetFactory extends AbstractBindingTarge public FluxMessageChannel fluxMessageChannel(String name) { FluxMessageChannel fluxMessageChannel = null; - if (context != null && context.containsBean(name)) { - try { - fluxMessageChannel = context.getBean(name, FluxMessageChannel.class); - } - catch (BeanCreationException e) { - // ignore - } + if (context.containsBean(name)) { + fluxMessageChannel = context.getBean(name, FluxMessageChannel.class); } if (fluxMessageChannel == null) { FluxMessageChannel channel = new FluxMessageChannel(); channel.setComponentName(name); - if (context != null && !context.containsBean(name)) { - context.registerBean(name, FluxMessageChannel.class, () -> channel); - } + context.registerBean(name, FluxMessageChannel.class, () -> channel); fluxMessageChannel = channel; } return fluxMessageChannel;