Add missing ObjectProvider for missing beans

Update `MetricsAutoConfiguration` to use an `ObjectProvider` to guard
against missing beans.

See gh-9970
This commit is contained in:
Phillip Webb 2017-09-14 14:53:59 -07:00
parent ddca0b7422
commit 21b645fba8
1 changed files with 4 additions and 2 deletions

View File

@ -114,10 +114,12 @@ public class MetricsAutoConfiguration {
MeterRegistryConfigurationSupport(MeterRegistry registry,
ObjectProvider<Collection<MeterRegistryConfigurer>> configurers,
MetricsProperties config, Collection<MeterBinder> binders) {
MetricsProperties config,
ObjectProvider<Collection<MeterBinder>> binders) {
configurers.getIfAvailable(Collections::emptyList)
.forEach((configurer) -> configurer.configureRegistry(registry));
binders.forEach((binder) -> binder.bindTo(registry));
binders.getIfAvailable(Collections::emptyList)
.forEach((binder) -> binder.bindTo(registry));
if (config.isUseGlobalRegistry()) {
Metrics.addRegistry(registry);
}