From b6f3bfbb53dce043c523d905e56706dd6fc21cc6 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 9 Dec 2019 14:13:59 +0100 Subject: [PATCH] GH-1865 Remove unecessary creation of function initializer Togethere with https://github.com/spring-cloud/spring-cloud-stream/commit/a2dc34a160a07181dc4953f504010622c5700ce9 commit this should address the issues where functions are being bootstrapped when annotation-based configuration is present Resolves #1865 --- .../stream/function/FunctionConfiguration.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/FunctionConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/FunctionConfiguration.java index 525a677d8..9e48a340a 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/FunctionConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/FunctionConfiguration.java @@ -129,12 +129,15 @@ public class FunctionConfiguration { BindingServiceProperties serviceProperties, ConfigurableApplicationContext applicationContext, FunctionBindingRegistrar bindingHolder, BinderAwareChannelResolver dynamicDestinationResolver) { - if (bindableProxyFactories == null) { - return null; - } + boolean shouldCreateInitializer = bindableProxyFactories != null + && (applicationContext.containsBean("output") + || ObjectUtils.isEmpty(applicationContext.getBeanNamesForAnnotation(EnableBinding.class))); + + return shouldCreateInitializer + ? new FunctionChannelBindingInitializer(functionCatalog, functionProperties, bindableProxyFactories, + serviceProperties, dynamicDestinationResolver) + : null; - return new FunctionChannelBindingInitializer(functionCatalog, functionProperties, bindableProxyFactories, - serviceProperties, dynamicDestinationResolver); } /*