From 6d6880627525fd5e72be50f49cd7f756550977a5 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sat, 27 Jan 2018 06:51:12 +0900 Subject: [PATCH] Polish Closes gh-11805 --- .../endpoint/web/WebEndpointAutoConfiguration.java | 4 ++-- .../endpoint/web/WebEndpointAutoConfigurationTests.java | 4 ++-- .../ControllerEndpointWebFluxIntegrationTests.java | 2 -- .../ControllerEndpointWebMvcIntegrationTests.java | 2 +- .../endpoint/annotation/AbstractDiscoveredEndpoint.java | 2 +- .../actuate/endpoint/annotation/EndpointDiscoverer.java | 6 +++--- .../ControllerEndpointHandlerMappingIntegrationTests.java | 2 +- .../ControllerEndpointHandlerMappingIntegrationTests.java | 2 +- .../boot/actuate/metrics/amqp/RabbitMetricsTests.java | 8 ++------ .../reactive/error/AbstractErrorWebExceptionHandler.java | 2 +- .../main/asciidoc/appendix-application-properties.adoc | 2 +- .../spring-boot-docs/src/main/asciidoc/howto.adoc | 4 ++-- .../boot/SpringApplicationRunListener.java | 1 + 13 files changed, 18 insertions(+), 23 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java index 4286838ad3..767e2ce1c2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java @@ -124,7 +124,7 @@ public class WebEndpointAutoConfiguration { } @Bean - public ExposeExcludePropertyEndpointFilter webIncludeExcludePropertyEndpointFilter() { + public ExposeExcludePropertyEndpointFilter webExposeExcludePropertyEndpointFilter() { Set expose = this.properties.getExpose(); Set exclude = this.properties.getExclude(); return new ExposeExcludePropertyEndpointFilter<>(ExposableWebEndpoint.class, @@ -132,7 +132,7 @@ public class WebEndpointAutoConfiguration { } @Bean - public ExposeExcludePropertyEndpointFilter controllerIncludeExcludePropertyEndpointFilter() { + public ExposeExcludePropertyEndpointFilter controllerExposeExcludePropertyEndpointFilter() { Set expose = this.properties.getExpose(); Set exclude = this.properties.getExclude(); return new ExposeExcludePropertyEndpointFilter<>( diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java index a8aa2b40f9..54cb1a1309 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java @@ -82,8 +82,8 @@ public class WebEndpointAutoConfigurationTests { public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() { this.contextRunner.run((context) -> assertThat(context) .getBeans(ExposeExcludePropertyEndpointFilter.class) - .containsKeys("webIncludeExcludePropertyEndpointFilter", - "controllerIncludeExcludePropertyEndpointFilter")); + .containsKeys("webExposeExcludePropertyEndpointFilter", + "controllerExposeExcludePropertyEndpointFilter")); } @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java index 8f5e3411aa..6e95ac2e16 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java @@ -32,7 +32,6 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration; -import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext; import org.springframework.security.authentication.TestingAuthenticationToken; @@ -75,7 +74,6 @@ public class ControllerEndpointWebFluxIntegrationTests { ReactiveManagementContextAutoConfiguration.class, AuditAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, WebFluxAutoConfiguration.class, ManagementContextAutoConfiguration.class, - AuditAutoConfiguration.class, DispatcherServletAutoConfiguration.class, BeansEndpointAutoConfiguration.class }) static class DefaultConfiguration { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java index 4ed7d83058..3bef93bc07 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java @@ -108,7 +108,7 @@ public class ControllerEndpointWebMvcIntegrationTests { WebEndpointAutoConfiguration.class, ServletManagementContextAutoConfiguration.class, AuditAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, WebMvcAutoConfiguration.class, - ManagementContextAutoConfiguration.class, AuditAutoConfiguration.class, + ManagementContextAutoConfiguration.class, DispatcherServletAutoConfiguration.class, BeansEndpointAutoConfiguration.class }) static class DefaultConfiguration { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java index 20ebc02178..622c80dd97 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java @@ -52,7 +52,7 @@ public abstract class AbstractDiscoveredEndpoint Collection operations) { super(id, enabledByDefault, operations); Assert.notNull(discoverer, "Discoverer must not be null"); - Assert.notNull(discoverer, "EndpointBean must not be null"); + Assert.notNull(endpointBean, "EndpointBean must not be null"); this.discoverer = discoverer; this.endpointBean = endpointBean; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index 674b64b0ee..9f51497a6c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -273,10 +273,10 @@ public abstract class EndpointDiscoverer, O exten /** * Determine if an endpoint bean should be exposed. Subclasses can override this * method to provide additional logic. - * @param extensionBean the extension bean - * @return {@code true} if the extension is exposed + * @param endpointBean the endpoint bean + * @return {@code true} if the endpoint is exposed */ - protected boolean isEndpointExposed(Object extensionBean) { + protected boolean isEndpointExposed(Object endpointBean) { return true; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java index 75be340a21..0409316532 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java @@ -61,7 +61,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory; */ public class ControllerEndpointHandlerMappingIntegrationTests { - public ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner( + private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner( AnnotationConfigReactiveWebServerApplicationContext::new) .withUserConfiguration(EndpointConfiguration.class, ExampleWebFluxEndpoint.class); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java index 242a9e5591..eca7bb9c84 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java @@ -60,7 +60,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory; */ public class ControllerEndpointHandlerMappingIntegrationTests { - public WebApplicationContextRunner contextRunner = new WebApplicationContextRunner( + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner( AnnotationConfigServletWebServerApplicationContext::new) .withUserConfiguration(EndpointConfiguration.class, ExampleMvcEndpoint.class); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetricsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetricsTests.java index 4b7457bc61..4f483c30e4 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetricsTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetricsTests.java @@ -33,7 +33,7 @@ public class RabbitMetricsTests { @Test public void connectionFactoryIsInstrumented() { - ConnectionFactory connectionFactory = mockConnectionFactory(); + ConnectionFactory connectionFactory = mock(ConnectionFactory.class); SimpleMeterRegistry registry = new SimpleMeterRegistry(); new RabbitMetrics(connectionFactory, "rabbit", null).bindTo(registry); registry.get("rabbit.connections"); @@ -41,7 +41,7 @@ public class RabbitMetricsTests { @Test public void connectionFactoryWithTagsIsInstrumented() { - ConnectionFactory connectionFactory = mockConnectionFactory(); + ConnectionFactory connectionFactory = mock(ConnectionFactory.class); SimpleMeterRegistry registry = new SimpleMeterRegistry(); new RabbitMetrics(connectionFactory, "test", Tags.of("env", "prod")) .bindTo(registry); @@ -50,8 +50,4 @@ public class RabbitMetricsTests { assertThat(registry.find("test.connections").tags("env", "dev").meter()).isNull(); } - private ConnectionFactory mockConnectionFactory() { - return mock(ConnectionFactory.class); - } - } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java index d39bee20c0..e1b5c2e8ee 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java @@ -193,7 +193,7 @@ public abstract class AbstractErrorWebExceptionHandler Date timestamp = (Date) error.get("timestamp"); builder.append("

Whitelabel Error Page

") .append("

This application has no configured error view, so you are seeing this as a fallback.

") - .append("
").append(timestamp.toString()) + .append("
").append(timestamp) .append("
").append("
There was an unexpected error (type=") .append(htmlEscape(error.get("error"))).append(", status=") .append(htmlEscape(error.get("status"))).append(").
"); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index c38b1c7520..371fa43580 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1365,8 +1365,8 @@ content into your application. Rather, pick only the properties that you need. management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed, it is sent to the StatsD server. management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. - management.metrics.jdbc.metric-name=data.source # Name of the metric for data source usage. management.metrics.jdbc.instrument=true # Instrument all available data sources. + management.metrics.jdbc.metric-name=data.source # Name of the metric for data source usage. management.metrics.rabbitmq.instrument=true # Instrument all available connection factories. management.metrics.rabbitmq.metric-name=rabbitmq # Name of the metric for RabbitMQ usage. management.metrics.use-global-registry=true # Whether auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index a007464bf6..2ce19df5fa 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -2140,7 +2140,7 @@ one and mark its `@Bean` as `@FlywayDataSource`. If you do so and want two data remember to create another one and mark it as `@Primary`. Alternatively, you can use Flyway's native `DataSource` by setting `spring.flyway.[url,user,password]` in external properties. Setting either `spring.flyway.url` or `spring.flyway.user` -is sufficent to cause Flyway to use its own `DataSource`. If any of the three +is sufficient to cause Flyway to use its own `DataSource`. If any of the three properties has not be set, the value of its equivalent `spring.datasource` property will be used. @@ -2179,7 +2179,7 @@ mark its `@Bean` as `@LiquibaseDataSource`. If you do so and you want two data s remember to create another one and mark it as `@Primary`. Alternatively, you can use Liquibase's native `DataSource` by setting `spring.liquibase.[url,user,password]` in external properties. Setting either `spring.liquibase.url` or `spring.liquibase.user` -is sufficent to cause Liquibase to use its own `DataSource`. If any of the three +is sufficient to cause Liquibase to use its own `DataSource`. If any of the three properties has not be set, the value of its equivalent `spring.datasource` property will be used. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java index 297b29879f..f74df169ab 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java @@ -66,6 +66,7 @@ public interface SpringApplicationRunListener { * {@link CommandLineRunner CommandLineRunners} and {@link ApplicationRunner * ApplicationRunners} have not been called. * @param context the application context. + * @since 2.0.0 */ void started(ConfigurableApplicationContext context);