From fd2b0ebb6acbf2ca756ca8998b4855f13c809c20 Mon Sep 17 00:00:00 2001 From: Phillip Verheyden Date: Fri, 14 Dec 2018 14:36:17 -0600 Subject: [PATCH] Polish around default binding IllegalStateException If no binders were found the exception should reflect that instead of indicating that multiple binders were found Resolves #1561 --- .../cloud/stream/binder/DefaultBinderFactory.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 add761836..ae495e5b9 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 @@ -122,8 +122,12 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl this.defaultBinderForBindingTargetType.put(bindingTargetType.getName(), configurationName); } else { - throw new IllegalStateException("A default binder has been requested, but there is more than " - + "one binder available for '" + bindingTargetType.getName() + "' : " + String countMsg = (candidatesForBindableType.size() == 0) + ? "are no binders" + : "is more than one binder"; + throw new IllegalStateException( + "A default binder has been requested, but there " + countMsg + + " available for '" + bindingTargetType.getName() + "' : " + StringUtils.collectionToCommaDelimitedString(candidatesForBindableType) + ", and no default binder has been set."); }