From ade40dc2bb66a7751a34f8bc6d5dfafa9194c789 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 2750e837f..5336ce6d7 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 @@ -153,8 +153,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."); }