Skip to content

Commit 22192c2

Browse files
committed
Polish "Make auto-config of RestTemplate metrics back off with no builder bean"
Closes gh-15842
1 parent 8f3c4db commit 22192c2

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/HttpClientMetricsAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
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.
@@ -39,6 +39,7 @@
3939
* @author Jon Schneider
4040
* @author Phillip Webb
4141
* @author Stephane Nicoll
42+
* @author Raheela Aslam
4243
* @since 2.1.0
4344
*/
4445
@Configuration

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @author Jon Schneider
3737
* @author Phillip Webb
38-
* @author raheela.aslam
38+
* @author Raheela Aslam
3939
*/
4040
@Configuration
4141
@ConditionalOnClass(RestTemplate.class)

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsConfigurationTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
* @author Stephane Nicoll
4444
* @author Jon Schneider
45-
* @author raheela.aslam
45+
* @author Raheela Aslam
4646
*/
4747
public class RestTemplateMetricsConfigurationTests {
4848

@@ -100,6 +100,16 @@ public void shouldNotDenyNorLogIfMaxUrisIsNotReached() {
100100
});
101101
}
102102

103+
@Test
104+
public void backsOffWhenRestTemplateBuilderIsMissing() {
105+
new ApplicationContextRunner().with(MetricsRun.simple())
106+
.withConfiguration(
107+
AutoConfigurations.of(HttpClientMetricsAutoConfiguration.class))
108+
.run((context) -> assertThat(context)
109+
.doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class)
110+
.doesNotHaveBean(MetricsRestTemplateCustomizer.class));
111+
}
112+
103113
private MeterRegistry getInitializedMeterRegistry(
104114
AssertableApplicationContext context) {
105115
MeterRegistry registry = context.getBean(MeterRegistry.class);
@@ -133,14 +143,4 @@ private RestTemplate mockRestTemplate(RestTemplateBuilder builder) {
133143
return restTemplate;
134144
}
135145

136-
@Test
137-
public void backsOffWhenRestTemplateBuilderIsMissing() {
138-
new ApplicationContextRunner().with(MetricsRun.simple())
139-
.withConfiguration(
140-
AutoConfigurations.of(HttpClientMetricsAutoConfiguration.class))
141-
.run((context) -> assertThat(context)
142-
.doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class)
143-
.doesNotHaveBean(MetricsRestTemplateCustomizer.class));
144-
}
145-
146146
}

0 commit comments

Comments
 (0)