Skip to content

Commit c84a0f5

Browse files
committed
Merge pull request #15798 from ayudovin
* pr/15798: Polish "Inject Map directly rather than via ObjectProvider" Inject Map directly rather than via ObjectProvider
2 parents 9d609ab + ede23ca commit c84a0f5

File tree

6 files changed

+19
-30
lines changed

6 files changed

+19
-30
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.cache;
1818

19-
import java.util.LinkedHashMap;
2019
import java.util.Map;
2120

22-
import org.springframework.beans.factory.ObjectProvider;
2321
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
2422
import org.springframework.boot.actuate.cache.CachesEndpoint;
2523
import org.springframework.boot.actuate.cache.CachesEndpointWebExtension;
@@ -48,9 +46,8 @@ public class CachesEndpointAutoConfiguration {
4846

4947
@Bean
5048
@ConditionalOnMissingBean
51-
public CachesEndpoint cachesEndpoint(
52-
ObjectProvider<Map<String, CacheManager>> cacheManagers) {
53-
return new CachesEndpoint(cacheManagers.getIfAvailable(LinkedHashMap::new));
49+
public CachesEndpoint cachesEndpoint(Map<String, CacheManager> cacheManagers) {
50+
return new CachesEndpoint(cacheManagers);
5451
}
5552

5653
@Bean

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,12 +16,10 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.health;
1818

19-
import java.util.Collections;
2019
import java.util.Map;
2120

2221
import reactor.core.publisher.Flux;
2322

24-
import org.springframework.beans.factory.ObjectProvider;
2523
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
2624
import org.springframework.boot.actuate.health.HealthAggregator;
2725
import org.springframework.boot.actuate.health.HealthIndicator;
@@ -87,13 +85,11 @@ static class ReactiveHealthIndicatorConfiguration {
8785
@Bean
8886
@ConditionalOnMissingBean
8987
public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry(
90-
ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators,
91-
ObjectProvider<Map<String, HealthIndicator>> healthIndicators) {
88+
Map<String, ReactiveHealthIndicator> reactiveHealthIndicators,
89+
Map<String, HealthIndicator> healthIndicators) {
9290
return new ReactiveHealthIndicatorRegistryFactory()
93-
.createReactiveHealthIndicatorRegistry(
94-
reactiveHealthIndicators
95-
.getIfAvailable(Collections::emptyMap),
96-
healthIndicators.getIfAvailable(Collections::emptyMap));
91+
.createReactiveHealthIndicatorRegistry(reactiveHealthIndicators,
92+
healthIndicators);
9793
}
9894

9995
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,10 +72,9 @@ public class DataSourceHealthIndicatorAutoConfiguration extends
7272

7373
private DataSourcePoolMetadataProvider poolMetadataProvider;
7474

75-
public DataSourceHealthIndicatorAutoConfiguration(
76-
ObjectProvider<Map<String, DataSource>> dataSources,
75+
public DataSourceHealthIndicatorAutoConfiguration(Map<String, DataSource> dataSources,
7776
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
78-
this.dataSources = filterDataSources(dataSources.getIfAvailable());
77+
this.dataSources = filterDataSources(dataSources);
7978
this.metadataProviders = metadataProviders.orderedStream()
8079
.collect(Collectors.toList());
8180
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jms/JmsHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020

2121
import javax.jms.ConnectionFactory;
2222

23-
import org.springframework.beans.factory.ObjectProvider;
2423
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthIndicatorConfiguration;
2524
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
2625
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
@@ -55,8 +54,8 @@ public class JmsHealthIndicatorAutoConfiguration extends
5554
private final Map<String, ConnectionFactory> connectionFactories;
5655

5756
public JmsHealthIndicatorAutoConfiguration(
58-
ObjectProvider<Map<String, ConnectionFactory>> connectionFactories) {
59-
this.connectionFactories = connectionFactories.getIfAvailable();
57+
Map<String, ConnectionFactory> connectionFactories) {
58+
this.connectionFactories = connectionFactories;
6059
}
6160

6261
@Bean

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthIndicatorAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import java.util.Map;
2020

21-
import org.springframework.beans.factory.ObjectProvider;
2221
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthIndicatorConfiguration;
2322
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
2423
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
@@ -53,8 +52,8 @@ public class MailHealthIndicatorAutoConfiguration extends
5352
private final Map<String, JavaMailSenderImpl> mailSenders;
5453

5554
public MailHealthIndicatorAutoConfiguration(
56-
ObjectProvider<Map<String, JavaMailSenderImpl>> mailSenders) {
57-
this.mailSenders = mailSenders.getIfAvailable();
55+
Map<String, JavaMailSenderImpl> mailSenders) {
56+
this.mailSenders = mailSenders;
5857
}
5958

6059
@Bean

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,13 +74,12 @@ public class QuartzAutoConfiguration {
7474

7575
public QuartzAutoConfiguration(QuartzProperties properties,
7676
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
77-
ObjectProvider<JobDetail[]> jobDetails,
78-
ObjectProvider<Map<String, Calendar>> calendars,
77+
ObjectProvider<JobDetail[]> jobDetails, Map<String, Calendar> calendars,
7978
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
8079
this.properties = properties;
8180
this.customizers = customizers;
8281
this.jobDetails = jobDetails.getIfAvailable();
83-
this.calendars = calendars.getIfAvailable();
82+
this.calendars = calendars;
8483
this.triggers = triggers.getIfAvailable();
8584
this.applicationContext = applicationContext;
8685
}

0 commit comments

Comments
 (0)