From 7b120c1c978eae7e3e333443881035ae7e838f95 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 4 May 2018 16:36:21 -0700 Subject: [PATCH] Formatting --- .../condition/OnEnabledEndpointCondition.java | 7 ++- ...grationGraphEndpointAutoConfiguration.java | 4 +- .../WebClientMetricsAutoConfiguration.java | 19 ++++---- .../WebFluxMetricsAutoConfiguration.java | 4 +- .../CachesEndpointAutoConfigurationTests.java | 9 ++-- .../ConditionalOnEnabledEndpointTests.java | 31 ++++++------- .../CachesEndpointDocumentationTests.java | 38 ++++++++-------- ...rationGraphEndpointDocumentationTests.java | 7 +-- ...onGraphEndpointAutoConfigurationTests.java | 4 +- ...ibernateMetricsAutoConfigurationTests.java | 7 +-- ...TemplateMetricsAutoConfigurationTests.java | 40 +++++++++-------- ...ebClientMetricsAutoConfigurationTests.java | 1 + .../WebFluxMetricsAutoConfigurationTests.java | 2 + .../boot/actuate/cache/CachesEndpoint.java | 34 +++++++------- .../DefaultWebClientExchangeTagsProvider.java | 1 + .../MetricsWebClientFilterFunction.java | 7 ++- .../client/WebClientExchangeTags.java | 17 +++---- .../client/WebClientExchangeTagsProvider.java | 4 +- .../web/reactive/client/package-info.java | 4 +- .../actuate/cache/CachesEndpointTests.java | 36 +++++++-------- .../CachesEndpointWebIntegrationTests.java | 33 +++++++------- ...ationGraphEndpointWebIntegrationTests.java | 14 +++--- ...ultWebClientExchangeTagsProviderTests.java | 45 ++++++++++--------- .../MetricsWebClientCustomizerTests.java | 1 + .../client/WebClientExchangeTagsTests.java | 20 +++++---- .../couchbase/CouchbaseConfiguration.java | 16 +++---- .../DispatcherServletAutoConfiguration.java | 2 +- .../boot/maven/AbstractRunMojo.java | 1 + .../springframework/boot/maven/RunMojo.java | 3 +- .../springframework/boot/maven/StartMojo.java | 3 +- .../boot/maven/EnvVariablesTests.java | 4 +- 31 files changed, 212 insertions(+), 206 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java index dc48b1ef5e..ef25e29311 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnEnabledEndpointCondition.java @@ -97,10 +97,9 @@ class OnEnabledEndpointCondition extends SpringBootCondition { return getEndpointAttributes(endpointType); } - private Class getEndpointType(ConditionContext context, - MethodMetadata metadata) { - Map attributes = metadata.getAnnotationAttributes( - ConditionalOnEnabledEndpoint.class.getName()); + private Class getEndpointType(ConditionContext context, MethodMetadata metadata) { + Map attributes = metadata + .getAnnotationAttributes(ConditionalOnEnabledEndpoint.class.getName()); if (attributes != null && attributes.containsKey("endpoint")) { Class target = (Class) attributes.get("endpoint"); if (target != Void.class) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java index ddc838a6bc..e6b29a8a2e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfiguration.java @@ -30,7 +30,8 @@ import org.springframework.integration.support.channel.HeaderChannelRegistry; import org.springframework.integration.support.management.graph.IntegrationGraphServer; /** - * {@link EnableAutoConfiguration Auto-configuration} for the {@link IntegrationGraphEndpoint}. + * {@link EnableAutoConfiguration Auto-configuration} for the + * {@link IntegrationGraphEndpoint}. * * @author Tim Ysewyn * @author Stephane Nicoll @@ -58,4 +59,3 @@ public class IntegrationGraphEndpointAutoConfiguration { } } - diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java index dc7d24a807..a0d0de491c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfiguration.java @@ -37,20 +37,21 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.reactive.function.client.WebClient; /** - * {@link EnableAutoConfiguration Auto-configuration} for instrumentation - * of {@link org.springframework.web.reactive.function.client.WebClient}. + * {@link EnableAutoConfiguration Auto-configuration} for instrumentation of + * {@link org.springframework.web.reactive.function.client.WebClient}. * - *

This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter} - * defined in {@link RestTemplateMetricsAutoConfiguration} for limiting the - * cardinality of "uri" tags. + *

+ * This is reusing the {@link io.micrometer.core.instrument.config.MeterFilter} defined in + * {@link RestTemplateMetricsAutoConfiguration} for limiting the cardinality of "uri" + * tags. * * @author Brian Clozel * @since 2.1.0 */ @Configuration @ConditionalOnClass(WebClient.class) -@AutoConfigureAfter({MetricsAutoConfiguration.class, - SimpleMetricsExportAutoConfiguration.class}) +@AutoConfigureAfter({ MetricsAutoConfiguration.class, + SimpleMetricsExportAutoConfiguration.class }) @AutoConfigureBefore(WebClientAutoConfiguration.class) @ConditionalOnBean(MeterRegistry.class) public class WebClientMetricsAutoConfiguration { @@ -62,8 +63,8 @@ public class WebClientMetricsAutoConfiguration { } @Bean - public MetricsWebClientCustomizer metricsWebClientCustomizer(MeterRegistry meterRegistry, - WebClientExchangeTagsProvider tagsProvider, + public MetricsWebClientCustomizer metricsWebClientCustomizer( + MeterRegistry meterRegistry, WebClientExchangeTagsProvider tagsProvider, MetricsProperties properties) { return new MetricsWebClientCustomizer(meterRegistry, tagsProvider, properties.getWeb().getClient().getRequestsMetricName()); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java index 86d957096b..9828805672 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java @@ -33,8 +33,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * {@link EnableAutoConfiguration Auto-configuration} for instrumentation - * of Spring WebFlux applications. + * {@link EnableAutoConfiguration Auto-configuration} for instrumentation of Spring + * WebFlux applications. * * @author Jon Schneider * @since 2.0.0 diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java index 9d193739bc..033783a751 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfigurationTests.java @@ -42,15 +42,14 @@ public class CachesEndpointAutoConfigurationTests { @Test public void runShouldHaveEndpointBean() { - this.contextRunner.withUserConfiguration(CacheConfiguration.class) - .run((context) -> - assertThat(context).hasSingleBean(CachesEndpoint.class)); + this.contextRunner.withUserConfiguration(CacheConfiguration.class).run( + (context) -> assertThat(context).hasSingleBean(CachesEndpoint.class)); } @Test public void runWithoutCacheManagerShouldHaveEndpointBean() { - this.contextRunner.run((context) -> - assertThat(context).hasSingleBean(CachesEndpoint.class)); + this.contextRunner.run( + (context) -> assertThat(context).hasSingleBean(CachesEndpoint.class)); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java index efccbf99bd..a83516afc2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java @@ -104,9 +104,10 @@ public class ConditionalOnEnabledEndpointTests { @Test public void outcomeWithReferenceWhenNoPropertiesShouldMatch() { - this.contextRunner.withUserConfiguration(FooEndpointEnabledByDefaultTrue.class, - ComponentEnabledIfEndpointIsEnabledConfiguration.class).run((context) -> - assertThat(context).hasBean("fooComponent")); + this.contextRunner + .withUserConfiguration(FooEndpointEnabledByDefaultTrue.class, + ComponentEnabledIfEndpointIsEnabledConfiguration.class) + .run((context) -> assertThat(context).hasBean("fooComponent")); } @Test @@ -114,8 +115,7 @@ public class ConditionalOnEnabledEndpointTests { this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=true") .withUserConfiguration(FooEndpointEnabledByDefaultTrue.class, ComponentEnabledIfEndpointIsEnabledConfiguration.class) - .run((context) -> - assertThat(context).hasBean("fooComponent")); + .run((context) -> assertThat(context).hasBean("fooComponent")); } @Test @@ -123,22 +123,23 @@ public class ConditionalOnEnabledEndpointTests { this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false") .withUserConfiguration(FooEndpointEnabledByDefaultTrue.class, ComponentEnabledIfEndpointIsEnabledConfiguration.class) - .run((context) -> - assertThat(context).doesNotHaveBean("fooComponent")); + .run((context) -> assertThat(context).doesNotHaveBean("fooComponent")); } @Test public void outcomeWithNoReferenceShouldFail() { - this.contextRunner.withUserConfiguration( - ComponentWithNoEndpointReferenceConfiguration.class).run((context) -> { - assertThat(context).hasFailed(); - assertThat(context.getStartupFailure().getCause().getMessage()).contains( - "No endpoint is specified and the return type of the @Bean method " - + "is neither an @Endpoint, nor an @EndpointExtension"); - }); + this.contextRunner + .withUserConfiguration( + ComponentWithNoEndpointReferenceConfiguration.class) + .run((context) -> { + assertThat(context).hasFailed(); + assertThat(context.getStartupFailure().getCause().getMessage()) + .contains( + "No endpoint is specified and the return type of the @Bean method " + + "is neither an @Endpoint, nor an @EndpointExtension"); + }); } - @Endpoint(id = "foo", enableByDefault = true) static class FooEndpointEnabledByDefaultTrue { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java index 117ce02993..8bff0fa755 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/CachesEndpointDocumentationTests.java @@ -45,6 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * Tests for generating documentation describing the {@link CachesEndpoint} + * * @author Stephane Nicoll */ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @@ -52,11 +53,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati private static final List levelFields = Arrays.asList( fieldWithPath("name").description("Cache name."), fieldWithPath("cacheManager").description("Cache manager name."), - fieldWithPath("target").description( - "Fully qualified name of the native cache.")); + fieldWithPath("target") + .description("Fully qualified name of the native cache.")); - private static final List requestParameters = Collections.singletonList( - parameterWithName("cacheManager") + private static final List requestParameters = Collections + .singletonList(parameterWithName("cacheManager") .description("Name of the cacheManager to qualify the cache. May be " + "omitted if the cache name is unique.") .optional()); @@ -67,12 +68,11 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati .andDo(MockMvcRestDocumentation.document("caches/all", responseFields( fieldWithPath("cacheManagers") .description("Cache managers keyed by id."), - fieldWithPath("cacheManagers.*") - .description("Caches in the application context keyed by " - + "name.")) - .andWithPrefix("cacheManagers.*.*.", fieldWithPath("target") - .description( - "Fully qualified name of the native cache.")))); + fieldWithPath("cacheManagers.*").description( + "Caches in the application context keyed by " + "name.")) + .andWithPrefix("cacheManagers.*.*.", + fieldWithPath("target").description( + "Fully qualified name of the native cache.")))); } @Test @@ -91,14 +91,14 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati @Test public void evictNamedCache() throws Exception { - this.mockMvc.perform( - delete("/actuator/caches/countries?cacheManager=anotherCacheManager")) - .andExpect(status().isNoContent()).andDo( - MockMvcRestDocumentation.document("caches/evict-named", + this.mockMvc + .perform(delete( + "/actuator/caches/countries?cacheManager=anotherCacheManager")) + .andExpect(status().isNoContent()) + .andDo(MockMvcRestDocumentation.document("caches/evict-named", requestParameters(requestParameters))); } - @Configuration @Import(BaseDocumentationConfiguration.class) static class TestConfiguration { @@ -106,10 +106,10 @@ public class CachesEndpointDocumentationTests extends MockMvcEndpointDocumentati @Bean public CachesEndpoint endpoint() { Map cacheManagers = new HashMap<>(); - cacheManagers.put("cacheManager", new ConcurrentMapCacheManager( - "countries", "cities")); - cacheManagers.put("anotherCacheManager", new ConcurrentMapCacheManager( - "countries")); + cacheManagers.put("cacheManager", + new ConcurrentMapCacheManager("countries", "cities")); + cacheManagers.put("anotherCacheManager", + new ConcurrentMapCacheManager("countries")); return new CachesEndpoint(cacheManagers); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java index 1e16977b79..d8587e1c9e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/IntegrationGraphEndpointDocumentationTests.java @@ -35,7 +35,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Tim Ysewyn */ -public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { +public class IntegrationGraphEndpointDocumentationTests + extends MockMvcEndpointDocumentationTests { @Test public void graph() throws Exception { @@ -45,8 +46,8 @@ public class IntegrationGraphEndpointDocumentationTests extends MockMvcEndpointD @Test public void rebuild() throws Exception { - this.mockMvc.perform(post("/actuator/integrationgraph")).andExpect(status() - .isNoContent()) + this.mockMvc.perform(post("/actuator/integrationgraph")) + .andExpect(status().isNoContent()) .andDo(MockMvcRestDocumentation.document("integrationgraph/rebuild")); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java index 3d34e6b776..1263f04e45 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integration/IntegrationGraphEndpointAutoConfigurationTests.java @@ -59,8 +59,8 @@ public class IntegrationGraphEndpointAutoConfigurationTests { @Test public void runWhenSpringIntegrationIsNotEnabledShouldNotHaveEndpointBean() { ApplicationContextRunner noSpringIntegrationRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of( - IntegrationGraphEndpointAutoConfiguration.class)); + .withConfiguration(AutoConfigurations + .of(IntegrationGraphEndpointAutoConfiguration.class)); noSpringIntegrationRunner.run((context) -> { assertThat(context).doesNotHaveBean(IntegrationGraphEndpoint.class); assertThat(context).doesNotHaveBean(IntegrationGraphServer.class); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java index beff4b2964..fe123f35aa 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java @@ -90,8 +90,9 @@ public class HibernateMetricsAutoConfigurationTests { @Test public void entityManagerFactoryInstrumentationCanBeDisabled() { - this.contextRunner.withPropertyValues("management.metrics.enable.hibernate=false", - "spring.jpa.properties.hibernate.generate_statistics:true") + this.contextRunner + .withPropertyValues("management.metrics.enable.hibernate=false", + "spring.jpa.properties.hibernate.generate_statistics:true") .run((context) -> { context.getBean(EntityManagerFactory.class) .unwrap(SessionFactory.class); @@ -130,7 +131,7 @@ public class HibernateMetricsAutoConfigurationTests { // ensure EntityManagerFactory is not an Hibernate SessionFactory assertThatThrownBy(() -> context.getBean(EntityManagerFactory.class) .unwrap(SessionFactory.class)) - .isInstanceOf(PersistenceException.class); + .isInstanceOf(PersistenceException.class); MeterRegistry registry = context.getBean(MeterRegistry.class); assertThat(registry.find("hibernate.statements").meter()).isNull(); }); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java index 0bd8cb5b33..62abdf3b6e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfigurationTests.java @@ -78,25 +78,27 @@ public class RestTemplateMetricsAutoConfigurationTests { this.contextRunner .withPropertyValues("management.metrics.web.client.max-uri-tags=10") .run((context) -> { - MetricsProperties properties = context.getBean(MetricsProperties.class); - int maxUriTags = properties.getWeb().getClient().getMaxUriTags(); - MeterRegistry registry = context.getBean(MeterRegistry.class); - RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class) - .build(); - MockRestServiceServer server = MockRestServiceServer - .createServer(restTemplate); - for (int i = 0; i < maxUriTags + 10; i++) { - server.expect(requestTo("/test/" + i)) - .andRespond(withStatus(HttpStatus.OK)); - } - for (int i = 0; i < maxUriTags + 10; i++) { - restTemplate.getForObject("/test/" + i, String.class); - } - assertThat(registry.get("http.client.requests").meters()).hasSize(maxUriTags); - assertThat(this.out.toString()) - .contains("Reached the maximum number of URI tags " - + "for 'http.client.requests'"); - }); + MetricsProperties properties = context + .getBean(MetricsProperties.class); + int maxUriTags = properties.getWeb().getClient().getMaxUriTags(); + MeterRegistry registry = context.getBean(MeterRegistry.class); + RestTemplate restTemplate = context.getBean(RestTemplateBuilder.class) + .build(); + MockRestServiceServer server = MockRestServiceServer + .createServer(restTemplate); + for (int i = 0; i < maxUriTags + 10; i++) { + server.expect(requestTo("/test/" + i)) + .andRespond(withStatus(HttpStatus.OK)); + } + for (int i = 0; i < maxUriTags + 10; i++) { + restTemplate.getForObject("/test/" + i, String.class); + } + assertThat(registry.get("http.client.requests").meters()) + .hasSize(maxUriTags); + assertThat(this.out.toString()) + .contains("Reached the maximum number of URI tags " + + "for 'http.client.requests'"); + }); } private void validateRestTemplate(RestTemplate restTemplate, MeterRegistry registry) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java index 0f2b726c6d..16b036329e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebClientMetricsAutoConfigurationTests.java @@ -116,6 +116,7 @@ public class WebClientMetricsAutoConfigurationTests { public WebClientExchangeTagsProvider customTagProvider() { return mock(WebClientExchangeTagsProvider.class); } + } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java index 5b025d23b1..b1760fa64d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java @@ -65,5 +65,7 @@ public class WebFluxMetricsAutoConfigurationTests { public WebFluxTagsProvider customWebFluxTagsProvider() { return mock(WebFluxTagsProvider.class); } + } + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java index 65b916db79..7f51bd4229 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java @@ -78,8 +78,8 @@ public class CachesEndpoint { */ @ReadOperation public CacheEntry cache(@Selector String cache, @Nullable String cacheManager) { - return extractUniqueCacheEntry(cache, getCacheEntries( - (name) -> name.equals(cache), safeEqual(cacheManager))); + return extractUniqueCacheEntry(cache, + getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager))); } /** @@ -95,23 +95,23 @@ public class CachesEndpoint { * Clear the specific {@link Cache}. * @param cache then name of the cache * @param cacheManager the name of the cacheManager (can be {@code null} - * @return {@code true} if the cache was cleared or {@code false} if no such cache exists + * @return {@code true} if the cache was cleared or {@code false} if no such cache + * exists * @throws NonUniqueCacheException if more than one cache with that name exist and no */ @DeleteOperation public boolean clearCache(@Selector String cache, @Nullable String cacheManager) { - CacheEntry entry = extractUniqueCacheEntry(cache, getCacheEntries( - (name) -> name.equals(cache), safeEqual(cacheManager))); + CacheEntry entry = extractUniqueCacheEntry(cache, + getCacheEntries((name) -> name.equals(cache), safeEqual(cacheManager))); return (entry != null && clearCache(entry)); } - private List getCacheEntries( - Predicate cacheNamePredicate, + private List getCacheEntries(Predicate cacheNamePredicate, Predicate cacheManagerNamePredicate) { List entries = new ArrayList<>(); this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate) - .forEach((cacheManagerName) -> entries.addAll( - getCacheEntries(cacheManagerName, cacheNamePredicate))); + .forEach((cacheManagerName) -> entries + .addAll(getCacheEntries(cacheManagerName, cacheNamePredicate))); return entries; } @@ -121,17 +121,15 @@ public class CachesEndpoint { List entries = new ArrayList<>(); cacheManager.getCacheNames().stream().filter(cacheNamePredicate) .map(cacheManager::getCache).filter(Objects::nonNull) - .forEach((cache) -> entries.add( - new CacheEntry(cache, cacheManagerName))); + .forEach((cache) -> entries.add(new CacheEntry(cache, cacheManagerName))); return entries; } - private CacheEntry extractUniqueCacheEntry(String cache, - List entries) { + private CacheEntry extractUniqueCacheEntry(String cache, List entries) { if (entries.size() > 1) { - throw new NonUniqueCacheException(cache, entries.stream() - .map(CacheEntry::getCacheManager).distinct() - .collect(Collectors.toList())); + throw new NonUniqueCacheException(cache, + entries.stream().map(CacheEntry::getCacheManager).distinct() + .collect(Collectors.toList())); } return (entries.isEmpty() ? null : entries.get(0)); } @@ -152,8 +150,8 @@ public class CachesEndpoint { } /** - * A report of available {@link Cache caches}, primarily intended for serialization - * to JSON. + * A report of available {@link Cache caches}, primarily intended for serialization to + * JSON. */ public static final class CachesReport { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java index b0ad69866b..d747703b33 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java @@ -47,4 +47,5 @@ public class DefaultWebClientExchangeTagsProvider WebClientExchangeTags.status(throwable)); } } + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java index 4946f46186..89468ff246 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java @@ -29,8 +29,8 @@ import org.springframework.web.reactive.function.client.ExchangeFilterFunction; import org.springframework.web.reactive.function.client.ExchangeFunction; /** - * {@link ExchangeFilterFunction} applied via a - * {@link MetricsWebClientCustomizer} to record metrics. + * {@link ExchangeFilterFunction} applied via a {@link MetricsWebClientCustomizer} to + * record metrics. * * @author Brian Clozel * @since 2.1.0 @@ -58,8 +58,7 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction { .doOnSuccessOrError((clientResponse, throwable) -> { Iterable tags = this.tagProvider.tags(clientRequest, clientResponse, throwable); - Timer.builder(this.metricName) - .tags(tags) + Timer.builder(this.metricName).tags(tags) .description("Timer of WebClient operation") .register(this.meterRegistry) .record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java index 8987632c99..ca852e3d6b 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java @@ -34,7 +34,8 @@ import org.springframework.web.reactive.function.client.WebClient; */ public final class WebClientExchangeTags { - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; + private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + + ".uriTemplate"; private static final Tag IO_ERROR = Tag.of("status", "IO_ERROR"); @@ -44,8 +45,8 @@ public final class WebClientExchangeTags { } /** - * Creates a {@code method} {@code Tag} for the - * {@link ClientHttpRequest#getMethod() method} of the given {@code request}. + * Creates a {@code method} {@code Tag} for the {@link ClientHttpRequest#getMethod() + * method} of the given {@code request}. * @param request the request * @return the method tag */ @@ -80,8 +81,8 @@ public final class WebClientExchangeTags { } /** - * Creates a {@code status} {@code Tag} derived from the - * exception thrown by the client. + * Creates a {@code status} {@code Tag} derived from the exception thrown by the + * client. * @param throwable the exception * @return the status tag */ @@ -90,9 +91,9 @@ public final class WebClientExchangeTags { } /** - * Create a {@code clientName} {@code Tag} derived from - * the {@link java.net.URI#getHost host} - * of the {@link ClientRequest#url() URL} of the given {@code request}. + * Create a {@code clientName} {@code Tag} derived from the + * {@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the + * given {@code request}. * @param request the request * @return the clientName tag */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java index 7444c332f9..ce1a443839 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java @@ -38,5 +38,7 @@ public interface WebClientExchangeTagsProvider { * @param throwable the exception (may be {@code null}) * @return tags to associate with metrics for the request and response exchange */ - Iterable tags(ClientRequest request, ClientResponse response, Throwable throwable); + Iterable tags(ClientRequest request, ClientResponse response, + Throwable throwable); + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java index 7459267757..7722c644a1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/package-info.java @@ -15,7 +15,7 @@ */ /** - * Actuator support for - * {@link org.springframework.web.reactive.function.client.WebClient} metrics. + * Actuator support for {@link org.springframework.web.reactive.function.client.WebClient} + * metrics. */ package org.springframework.boot.actuate.metrics.web.reactive.client; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java index beed1adc32..7a26912668 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointTests.java @@ -51,17 +51,17 @@ public class CachesEndpointTests { @Test public void allCachesWithSingleCacheManager() { - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", new ConcurrentMapCacheManager("a", "b"))); + CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", + new ConcurrentMapCacheManager("a", "b"))); Map> allDescriptors = endpoint.caches() .getCacheManagers(); assertThat(allDescriptors).containsOnlyKeys("test"); Map descriptors = allDescriptors.get("test"); assertThat(descriptors).containsOnlyKeys("a", "b"); - assertThat(descriptors.get("a").getTarget()).isEqualTo( - ConcurrentHashMap.class.getName()); - assertThat(descriptors.get("b").getTarget()).isEqualTo( - ConcurrentHashMap.class.getName()); + assertThat(descriptors.get("a").getTarget()) + .isEqualTo(ConcurrentHashMap.class.getName()); + assertThat(descriptors.get("b").getTarget()) + .isEqualTo(ConcurrentHashMap.class.getName()); } @Test @@ -79,8 +79,8 @@ public class CachesEndpointTests { @Test public void namedCacheWithSingleCacheManager() { - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", new ConcurrentMapCacheManager("b", "a"))); + CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", + new ConcurrentMapCacheManager("b", "a"))); CacheEntry entry = endpoint.cache("a", null); assertThat(entry).isNotNull(); assertThat(entry.getCacheManager()).isEqualTo("test"); @@ -103,8 +103,8 @@ public class CachesEndpointTests { @Test public void namedCacheWithUnknownCache() { - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", new ConcurrentMapCacheManager("b", "a"))); + CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", + new ConcurrentMapCacheManager("b", "a"))); CacheEntry entry = endpoint.cache("unknown", null); assertThat(entry).isNull(); } @@ -135,8 +135,8 @@ public class CachesEndpointTests { public void clearAllCaches() { Cache a = mockCache("a"); Cache b = mockCache("b"); - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", cacheManager(a, b))); + CachesEndpoint endpoint = new CachesEndpoint( + Collections.singletonMap("test", cacheManager(a, b))); endpoint.clearCaches(); verify(a).clear(); verify(b).clear(); @@ -146,8 +146,8 @@ public class CachesEndpointTests { public void clearCache() { Cache a = mockCache("a"); Cache b = mockCache("b"); - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", cacheManager(a, b))); + CachesEndpoint endpoint = new CachesEndpoint( + Collections.singletonMap("test", cacheManager(a, b))); assertThat(endpoint.clearCache("a", null)).isTrue(); verify(a).clear(); verify(b, never()).clear(); @@ -184,8 +184,8 @@ public class CachesEndpointTests { @Test public void clearCacheWithUnknownCache() { Cache a = mockCache("a"); - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", cacheManager(a))); + CachesEndpoint endpoint = new CachesEndpoint( + Collections.singletonMap("test", cacheManager(a))); assertThat(endpoint.clearCache("unknown", null)).isFalse(); verify(a, never()).clear(); } @@ -193,8 +193,8 @@ public class CachesEndpointTests { @Test public void clearCacheWithUnknownCacheManager() { Cache a = mockCache("a"); - CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap( - "test", cacheManager(a))); + CachesEndpoint endpoint = new CachesEndpoint( + Collections.singletonMap("test", cacheManager(a))); assertThat(endpoint.clearCache("a", "unknown")).isFalse(); verify(a, never()).clear(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java index e10dc27b34..95a664a351 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cache/CachesEndpointWebIntegrationTests.java @@ -34,7 +34,8 @@ import org.springframework.test.web.reactive.server.WebTestClient; import static org.assertj.core.api.Assertions.assertThat; /** - * Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and WebFlux. + * Integration tests for {@link CachesEndpoint} exposed by Jersey, Spring MVC, and + * WebFlux. * * @author Stephane Nicoll */ @@ -48,23 +49,22 @@ public class CachesEndpointWebIntegrationTests { @Test public void allCaches() { client.get().uri("/actuator/caches").exchange().expectStatus().isOk().expectBody() - .jsonPath("cacheManagers.one.a.target").isEqualTo( - ConcurrentHashMap.class.getName()) - .jsonPath("cacheManagers.one.b.target").isEqualTo( - ConcurrentHashMap.class.getName()) - .jsonPath("cacheManagers.two.a.target").isEqualTo( - ConcurrentHashMap.class.getName()) - .jsonPath("cacheManagers.two.c.target").isEqualTo( - ConcurrentHashMap.class.getName()); + .jsonPath("cacheManagers.one.a.target") + .isEqualTo(ConcurrentHashMap.class.getName()) + .jsonPath("cacheManagers.one.b.target") + .isEqualTo(ConcurrentHashMap.class.getName()) + .jsonPath("cacheManagers.two.a.target") + .isEqualTo(ConcurrentHashMap.class.getName()) + .jsonPath("cacheManagers.two.c.target") + .isEqualTo(ConcurrentHashMap.class.getName()); } @Test public void namedCache() { client.get().uri("/actuator/caches/b").exchange().expectStatus().isOk() - .expectBody() - .jsonPath("name").isEqualTo("b") - .jsonPath("cacheManager").isEqualTo("one") - .jsonPath("target").isEqualTo(ConcurrentHashMap.class.getName()); + .expectBody().jsonPath("name").isEqualTo("b").jsonPath("cacheManager") + .isEqualTo("one").jsonPath("target") + .isEqualTo(ConcurrentHashMap.class.getName()); } @Test @@ -75,8 +75,7 @@ public class CachesEndpointWebIntegrationTests { @Test public void namedCacheWithNonUniqueName() { - client.get().uri("/actuator/caches/a").exchange().expectStatus() - .isBadRequest(); + client.get().uri("/actuator/caches/a").exchange().expectStatus().isBadRequest(); } @Test @@ -95,11 +94,9 @@ public class CachesEndpointWebIntegrationTests { @Test public void clearNamedCacheWithNonUniqueName() { - client.get().uri("/actuator/caches/a").exchange().expectStatus() - .isBadRequest(); + client.get().uri("/actuator/caches/a").exchange().expectStatus().isBadRequest(); } - @Configuration static class TestConfiguration { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java index 9fc6fe2103..00a62969b9 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/integration/IntegrationGraphEndpointWebIntegrationTests.java @@ -28,7 +28,8 @@ import org.springframework.integration.support.management.graph.IntegrationGraph import org.springframework.test.web.reactive.server.WebTestClient; /** - * Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC, and WebFlux. + * Integration tests for {@link IntegrationGraphEndpoint} exposed by Jersey, Spring MVC, + * and WebFlux. * * @author Tim Ysewyn */ @@ -39,8 +40,8 @@ public class IntegrationGraphEndpointWebIntegrationTests { @Test public void graph() { - client.get().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON).exchange() - .expectStatus().isOk().expectBody() + client.get().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON) + .exchange().expectStatus().isOk().expectBody() .jsonPath("contentDescriptor.providerVersion").isNotEmpty() .jsonPath("contentDescriptor.providerFormatVersion").isEqualTo(1.0f) .jsonPath("contentDescriptor.provider").isEqualTo("spring-integration"); @@ -48,8 +49,8 @@ public class IntegrationGraphEndpointWebIntegrationTests { @Test public void rebuild() { - client.post().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON).exchange() - .expectStatus().isNoContent(); + client.post().uri("/actuator/integrationgraph").accept(MediaType.APPLICATION_JSON) + .exchange().expectStatus().isNoContent(); } @Configuration @@ -57,7 +58,8 @@ public class IntegrationGraphEndpointWebIntegrationTests { public static class TestConfiguration { @Bean - public IntegrationGraphEndpoint endpoint(IntegrationGraphServer integrationGraphServer) { + public IntegrationGraphEndpoint endpoint( + IntegrationGraphServer integrationGraphServer) { return new IntegrationGraphEndpoint(integrationGraphServer); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java index 6c43347295..61edf696a7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.metrics.web.reactive.client; - import java.io.IOException; import java.net.URI; @@ -41,7 +40,8 @@ import static org.mockito.Mockito.mock; */ public class DefaultWebClientExchangeTagsProviderTests { - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; + private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + + ".uriTemplate"; private WebClientExchangeTagsProvider tagsProvider = new DefaultWebClientExchangeTagsProvider(); @@ -52,8 +52,10 @@ public class DefaultWebClientExchangeTagsProviderTests { @Before public void setup() { this.request = ClientRequest - .create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "http://example.org/projects/{project}") + .create(HttpMethod.GET, + URI.create("http://example.org/projects/spring-boot")) + .attribute(URI_TEMPLATE_ATTRIBUTE, + "http://example.org/projects/{project}") .build(); this.response = mock(ClientResponse.class); given(this.response.statusCode()).willReturn(HttpStatus.OK); @@ -62,38 +64,37 @@ public class DefaultWebClientExchangeTagsProviderTests { @Test public void tagsShouldBePopulated() { Iterable tags = this.tagsProvider.tags(this.request, this.response, null); - assertThat(tags).containsExactlyInAnyOrder( - Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("clientName", "example.org"), Tag.of("status", "200")); + assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), + Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"), + Tag.of("status", "200")); } @Test public void tagsWhenNoUriTemplateShouldProvideUriPath() { - ClientRequest request = ClientRequest - .create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot")) - .build(); + ClientRequest request = ClientRequest.create(HttpMethod.GET, + URI.create("http://example.org/projects/spring-boot")).build(); Iterable tags = this.tagsProvider.tags(request, this.response, null); - assertThat(tags).containsExactlyInAnyOrder( - Tag.of("method", "GET"), Tag.of("uri", "/projects/spring-boot"), + assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), + Tag.of("uri", "/projects/spring-boot"), Tag.of("clientName", "example.org"), Tag.of("status", "200")); } @Test public void tagsWhenIoExceptionShouldReturnIoErrorStatus() { - Iterable tags = this.tagsProvider.tags(this.request, - null, new IOException()); - assertThat(tags).containsExactlyInAnyOrder( - Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("clientName", "example.org"), Tag.of("status", "IO_ERROR")); + Iterable tags = this.tagsProvider.tags(this.request, null, + new IOException()); + assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), + Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"), + Tag.of("status", "IO_ERROR")); } @Test public void tagsWhenExceptionShouldReturnClientErrorStatus() { - Iterable tags = this.tagsProvider.tags(this.request, - null, new IllegalArgumentException()); - assertThat(tags).containsExactlyInAnyOrder( - Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR")); + Iterable tags = this.tagsProvider.tags(this.request, null, + new IllegalArgumentException()); + assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), + Tag.of("uri", "/projects/{project}"), Tag.of("clientName", "example.org"), + Tag.of("status", "CLIENT_ERROR")); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java index 173cfdbdf1..31f5e5324d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientCustomizerTests.java @@ -60,4 +60,5 @@ public class MetricsWebClientCustomizerTests { this.clientBuilder.filters((filters) -> assertThat(filters).hasSize(1).first() .isInstanceOf(MetricsWebClientFilterFunction.class)); } + } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java index f3dce2b13d..ac8d88520f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java @@ -40,7 +40,8 @@ import static org.mockito.Mockito.mock; */ public class WebClientExchangeTagsTests { - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; + private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + + ".uriTemplate"; private ClientRequest request; @@ -49,8 +50,10 @@ public class WebClientExchangeTagsTests { @Before public void setup() { this.request = ClientRequest - .create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "http://example.org/projects/{project}") + .create(HttpMethod.GET, + URI.create("http://example.org/projects/spring-boot")) + .attribute(URI_TEMPLATE_ATTRIBUTE, + "http://example.org/projects/{project}") .build(); this.response = mock(ClientResponse.class); given(this.response.statusCode()).willReturn(HttpStatus.OK); @@ -71,18 +74,17 @@ public class WebClientExchangeTagsTests { @Test public void uriWhenRelativeTemplateIsAvailableShouldReturnTemplate() { this.request = ClientRequest - .create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}") - .build(); + .create(HttpMethod.GET, + URI.create("http://example.org/projects/spring-boot")) + .attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}").build(); assertThat(WebClientExchangeTags.uri(this.request)) .isEqualTo(Tag.of("uri", "/projects/{project}")); } @Test public void uriWhenTemplateIsMissingShouldReturnPath() { - this.request = ClientRequest - .create(HttpMethod.GET, URI.create("http://example.org/projects/spring-boot")) - .build(); + this.request = ClientRequest.create(HttpMethod.GET, + URI.create("http://example.org/projects/spring-boot")).build(); assertThat(WebClientExchangeTags.uri(this.request)) .isEqualTo(Tag.of("uri", "/projects/spring-boot")); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java index ac5c688ef1..567cddc869 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseConfiguration.java @@ -59,8 +59,7 @@ public class CouchbaseConfiguration { @Bean @Primary public Cluster couchbaseCluster() { - return CouchbaseCluster.create(couchbaseEnvironment(), - determineBootstrapHosts()); + return CouchbaseCluster.create(couchbaseEnvironment(), determineBootstrapHosts()); } /** @@ -75,10 +74,8 @@ public class CouchbaseConfiguration { @Primary @DependsOn("couchbaseClient") public ClusterInfo couchbaseClusterInfo() { - return couchbaseCluster() - .clusterManager(this.properties.getBucket().getName(), - this.properties.getBucket().getPassword()) - .info(); + return couchbaseCluster().clusterManager(this.properties.getBucket().getName(), + this.properties.getBucket().getPassword()).info(); } @Bean @@ -113,8 +110,8 @@ public class CouchbaseConfiguration { builder = builder.viewServiceConfig(getViewServiceConfig(endpoints)); } if (timeouts.getSocketConnect() != null) { - builder = builder.socketConnectTimeout( - (int) timeouts.getSocketConnect().toMillis()); + builder = builder + .socketConnectTimeout((int) timeouts.getSocketConnect().toMillis()); } if (timeouts.getView() != null) { builder = builder.viewTimeout(timeouts.getView().toMillis()); @@ -147,8 +144,7 @@ public class CouchbaseConfiguration { private T getServiceConfig(CouchbaseService service, Integer fallback, BiFunction factory) { if (service.getMinEndpoints() != 1 || service.getMaxEndpoints() != 1) { - return factory.apply(service.getMinEndpoints(), - service.getMaxEndpoints()); + return factory.apply(service.getMinEndpoints(), service.getMaxEndpoints()); } int endpoints = (fallback != null ? fallback : 1); return factory.apply(endpoints, endpoints); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java index cd2ac0dd33..61e0a1a4e5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index a132833501..2bc4280bc8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -578,6 +578,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { } return String.format("-D%s=\"%s\"", key, value); } + } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index cf75bd6b50..9da8315a5b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -67,8 +67,7 @@ public class RunMojo extends AbstractRunMojo { @Override protected void runWithForkedJvm(File workingDirectory, List args, - Map environmentVariables) - throws MojoExecutionException { + Map environmentVariables) throws MojoExecutionException { try { RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java index 151981c6c2..14da020d50 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java @@ -103,8 +103,7 @@ public class StartMojo extends AbstractRunMojo { } private RunProcess runProcess(File workingDirectory, List args, - Map environmentVariables) - throws MojoExecutionException { + Map environmentVariables) throws MojoExecutionException { try { RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java index 21242e19b7..e574cd1b3f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/EnvVariablesTests.java @@ -39,8 +39,8 @@ public class EnvVariablesTests { @Test public void asArray() { - assertThat(new EnvVariables(getTestArgs()).asArray()) - .contains("key=My Value", "key1= tt ", "key2= ", "key3="); + assertThat(new EnvVariables(getTestArgs()).asArray()).contains("key=My Value", + "key1= tt ", "key2= ", "key3="); } @Test