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
This commit is contained in:
Phillip Verheyden
2018-12-14 14:36:17 -06:00
committed by Oleg Zhurakousky
parent 795aadc7b5
commit ade40dc2bb

View File

@@ -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.");
}