From 1049a3c6fc5c2fe62fe38e470f97cb1ebcc7ae7c Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Thu, 29 Apr 2021 19:30:47 -0400 Subject: [PATCH] Native compilation changes This commit effectively reverts the changes introduced in d9f8653e42f56e19a15fce59bb58fa72445e1ea7. Basically, removing the changes introduced for supporting multi binders when binders are registered through spring.factories. Binders are still expected to provide spring.binders to register them. --- .../stream/binder/DefaultBinderFactory.java | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) 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 965be3954..6cb03ddca 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 @@ -26,7 +26,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Optional; import java.util.Set; import org.apache.commons.logging.Log; @@ -130,44 +129,24 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl Map binders = this.context == null ? Collections.emptyMap() : this.context.getBeansOfType(Binder.class); Binder binder; - - String bindingTargetTypeName = StringUtils.hasText(name) ? name : bindingTargetType.getSimpleName().toLowerCase(); - final BinderConfiguration binderConfiguration = this.binderConfigurations.get(name); - if (binderConfiguration != null && binderConfiguration.getBinderType() != null) { - bindingTargetTypeName = binderConfiguration.getBinderType(); + if (StringUtils.hasText(binderName) && binders.containsKey(binderName)) { + binder = (Binder) this.context + .getBean(binderName); } - - String[] bindingTargetTypeNameForLambda = new String[]{bindingTargetTypeName}; - final Optional foundBinder = binders.keySet().stream().filter(b -> b.equals(bindingTargetTypeNameForLambda[0])).findFirst(); - if (foundBinder.isPresent()) { // found a match - now do all the customizations. - binder = binders.get(foundBinder.get()); - if (!CollectionUtils.isEmpty(this.listeners)) { - for (Listener binderFactoryListener : this.listeners) { - binderFactoryListener.afterBinderContextInitialized(bindingTargetTypeName, - this.context); - } - } + else if (binders.size() == 1) { + binder = binders.values().iterator().next(); + } + else if (binders.size() > 1) { + throw new IllegalStateException( + "Multiple binders are available, however neither default nor " + + "per-destination binder name is provided. Available binders are " + + binders.keySet()); } else { - if (StringUtils.hasText(binderName) && binders.containsKey(binderName)) { - binder = (Binder) this.context - .getBean(binderName); - } - else if (binders.size() == 1) { - binder = binders.values().iterator().next(); - } - else if (binders.size() > 1) { - throw new IllegalStateException( - "Multiple binders are available, however neither default nor " - + "per-destination binder name is provided. Available binders are " - + binders.keySet()); - } - else { - /* - * This is the fall back to the old bootstrap that relies on spring.binders. - */ - binder = this.doGetBinder(binderName, bindingTargetType); - } + /* + * This is the fall back to the old bootstrap that relies on spring.binders. + */ + binder = this.doGetBinder(binderName, bindingTargetType); } if (this.binderCustomizer != null) { this.binderCustomizer.customize(binder, binderName);