Binder name in actuator binding endpoints

- Fixing an issue where binder name is broken in bindings endpoint
   when default-binder property is provided with multiple binders
   on the classpath.

Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2716
This commit is contained in:
Soby Chacko
2023-04-20 13:19:23 -04:00
parent 1856271ae1
commit 07d28f51ea

View File

@@ -222,6 +222,9 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
DefaultBinderTypeRegistry binderTypeRegistry =
AbstractMessageChannelBinder.this.getApplicationContext().getBean(DefaultBinderTypeRegistry.class);
Map<String, BinderType> binderTypes = binderTypeRegistry.getAll();
if (binderTypes.entrySet().size() > 1 && getBindingServiceProperties().getDefaultBinder() != null) {
return getBindingServiceProperties().getDefaultBinder();
}
Assert.isTrue(binderTypes.entrySet().size() == 1, "More than one binder types found, but no binder specified on the binding");
return binderTypes.keySet().iterator().next();
}
@@ -232,6 +235,9 @@ public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,
return resolveFromDefaultBinder();
}
else {
if (bindingServiceProperties.getBinders().get(binder) == null) {
return binder;
}
return bindingServiceProperties.getBinders().get(binder).getType();
}
}