From 6027508cf7fd08a733e3c97c8b92d179066fbdb3 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 11 Nov 2022 22:34:43 +0900 Subject: [PATCH 1/2] Polish See gh-33108 --- ...ServerRequestObservationConventionAdapter.java | 3 +-- .../tracing/zipkin/ZipkinRestTemplateSender.java | 2 +- .../tracing/zipkin/ZipkinWebClientSender.java | 2 +- ...rRequestObservationConventionAdapterTests.java | 3 ++- .../boot/actuate/health/HttpCodeStatusMapper.java | 2 +- .../boot/autoconfigure/mongo/MongoProperties.java | 2 +- ...itionEvaluationReportLoggingListenerTests.java | 2 +- .../src/docs/asciidoc/actuator/metrics.adoc | 2 +- .../src/docs/asciidoc/features/testing.adoc | 2 +- .../autoconfigure/data/jdbc/DataJdbcTest.java | 2 +- ...bservabilityContextCustomizerFactoryTests.java | 4 ++-- .../context/SpringBootContextLoaderTests.java | 15 +++++---------- ...gBootTestUseMainMethodWithPropertiesTests.java | 4 +--- .../PropertyDescriptorResolver.java | 2 +- .../src/docs/asciidoc/aot.adoc | 2 +- .../undertow/AccessLogHttpHandlerFactory.java | 2 +- 16 files changed, 22 insertions(+), 29 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java index d040ecba32..43689a962a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java @@ -59,8 +59,7 @@ class ServerRequestObservationConventionAdapter implements ServerRequestObservat } ServerRequestObservationConventionAdapter(String name, List contributors) { - this.name = name; - this.tagsProvider = new DefaultWebFluxTagsProvider(contributors); + this(name, new DefaultWebFluxTagsProvider(contributors)); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSender.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSender.java index 754815ecbe..d29e9eee60 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSender.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinRestTemplateSender.java @@ -24,7 +24,7 @@ import org.springframework.http.HttpMethod; import org.springframework.web.client.RestTemplate; /** - * A {@link HttpSender} which uses {@link RestTemplate} for HTTP communication. + * An {@link HttpSender} which uses {@link RestTemplate} for HTTP communication. * * @author Moritz Halbritter * @author Stefan Bratanov diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSender.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSender.java index 2db94cbe59..31ab6f5f75 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSender.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinWebClientSender.java @@ -25,7 +25,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.reactive.function.client.WebClient; /** - * A {@link HttpSender} which uses {@link WebClient} for HTTP communication. + * An {@link HttpSender} which uses {@link WebClient} for HTTP communication. * * @author Stefan Bratanov */ diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java index e20d4cfef5..c208984e21 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java @@ -21,6 +21,7 @@ import java.util.List; import io.micrometer.common.KeyValue; import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.Tags; import io.micrometer.observation.Observation; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -96,7 +97,7 @@ class ServerRequestObservationConventionAdapterTests { @Override public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, Throwable exception) { - return List.of(Tag.of("custom", "value")); + return Tags.of("custom", "value"); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HttpCodeStatusMapper.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HttpCodeStatusMapper.java index 10d9d291d4..749ea28532 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HttpCodeStatusMapper.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HttpCodeStatusMapper.java @@ -27,7 +27,7 @@ package org.springframework.boot.actuate.health; public interface HttpCodeStatusMapper { /** - * A {@link HttpCodeStatusMapper} instance using default mappings. + * An {@link HttpCodeStatusMapper} instance using default mappings. * @since 2.3.0 */ HttpCodeStatusMapper DEFAULT = new SimpleHttpCodeStatusMapper(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index d8c96fb438..c5b092927d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java @@ -63,7 +63,7 @@ public class MongoProperties { /** * Additional server hosts. Cannot be set with URI or if 'host' is not specified. - * Additional hosts will use the default mongo port of 27017, if you want to use a + * Additional hosts will use the default mongo port of 27017. If you want to use a * different port you can use the "host:port" syntax. */ private List additionalHosts; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListenerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListenerTests.java index 9629cc94b1..a3a9fb2ae3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListenerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListenerTests.java @@ -81,7 +81,7 @@ class ConditionEvaluationReportLoggingListenerTests { assertThatExceptionOfType(Exception.class).isThrownBy(context::refresh) .satisfies((ex) -> withInfoLogging(() -> context.publishEvent( new ApplicationFailedEvent(new SpringApplication(), new String[0], context, ex)))); - assertThat(output).doesNotContain("CONDITONS EVALUATION REPORT") + assertThat(output).doesNotContain("CONDITIONS EVALUATION REPORT") .contains("re-run your application with 'debug' enabled"); } diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc index fdd1bd4064..e45f8cb669 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc @@ -516,7 +516,7 @@ The following example `scrape_config` adds to `prometheus.yml`: ---- https://prometheus.io/docs/prometheus/latest/feature_flags/#exemplars-storage[Prometheus Exemplars] are also supported. -To enable this feature, a `SpanContextSupplier` bean should present. +To enable this feature, a `SpanContextSupplier` bean should be present. If you use https://micrometer.io/docs/tracing[Micrometer Tracing], this will be auto-configured for you, but you can always create your own if you want. Please check the https://prometheus.io/docs/prometheus/latest/feature_flags/#exemplars-storage[Prometheus Docs], since this feature needs to be explicitly enabled on Prometheus' side, and it is only supported using the https://github.com/OpenObservability/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#exemplars[OpenMetrics] format. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc index 2063e875cd..613130676f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc @@ -579,7 +579,7 @@ If you prefer your test to run against a real database, you can use the `@AutoCo ==== Auto-configured Data JDBC Tests `@DataJdbcTest` is similar to `@JdbcTest` but is for tests that use Spring Data JDBC repositories. By default, it configures an in-memory embedded database, a `JdbcTemplate`, and Spring Data JDBC repositories. -Only `AbstractJdbcConfiguration` sub-classes are scanned when the `@DataJdbcTest` annotation is used, regular `@Component` and `@ConfigurationProperties` beans are not scanned. +Only `AbstractJdbcConfiguration` subclasses are scanned when the `@DataJdbcTest` annotation is used, regular `@Component` and `@ConfigurationProperties` beans are not scanned. `@EnableConfigurationProperties` can be used to include `@ConfigurationProperties` beans. TIP: A list of the auto-configurations that are enabled by `@DataJdbcTest` can be <>. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java index 0b62020510..02bb369949 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java @@ -44,7 +44,7 @@ import org.springframework.transaction.annotation.Transactional; * Data JDBC components. *

* Using this annotation will disable full auto-configuration, scan for - * {@code AbstractJdbcConfiguration} sub-classes, and apply only configuration relevant to + * {@code AbstractJdbcConfiguration} subclasses, and apply only configuration relevant to * Data JDBC tests. *

* By default, tests annotated with {@code @DataJdbcTest} are transactional and roll back diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java index f919b15022..bb3b4010d2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java @@ -20,7 +20,6 @@ import java.util.Collections; import io.micrometer.tracing.Tracer; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; import org.springframework.boot.context.annotation.UserConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; @@ -33,6 +32,7 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.test.context.ContextCustomizer; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; /** * Tests for {@link AutoConfigureObservability} and @@ -197,7 +197,7 @@ class ObservabilityContextCustomizerFactoryTests { @Bean Tracer customTracer() { - return Mockito.mock(Tracer.class); + return mock(Tracer.class); } } diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java index 69a5d7ce79..70c4dd0c84 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootContextLoaderTests.java @@ -354,8 +354,7 @@ class SpringBootContextLoaderTests { } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) public static class ConfigWithMain { public static void main(String[] args) { @@ -364,14 +363,12 @@ class SpringBootContextLoaderTests { } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) static class ConfigWithNoMain { } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) public static class ConfigWithMainWithBeanThrowingException { public static void main(String[] args) { @@ -385,8 +382,7 @@ class SpringBootContextLoaderTests { } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) static class ConfigWithNoMainWithBeanThrowingException { @Bean @@ -396,8 +392,7 @@ class SpringBootContextLoaderTests { } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) public static class ConfigWithMainThrowingException { public static void main(String[] args) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestUseMainMethodWithPropertiesTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestUseMainMethodWithPropertiesTests.java index c0b8f6943b..c6fdb7f8b5 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestUseMainMethodWithPropertiesTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestUseMainMethodWithPropertiesTests.java @@ -23,7 +23,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.test.context.SpringBootTest.UseMainMethod; import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; @@ -44,8 +43,7 @@ class SpringBootTestUseMainMethodWithPropertiesTests { assertThat(this.applicationContext.getEnvironment().getProperty("test")).isEqualTo("123"); } - @Configuration(proxyBeanMethods = false) - @SpringBootConfiguration + @SpringBootConfiguration(proxyBeanMethods = false) public static class ConfigWithMain { public static void main(String[] args) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java index 0e4357983b..2bc303d7ab 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java @@ -205,7 +205,7 @@ class PropertyDescriptorResolver { MetadataGenerationEnvironment env) { if (constructors.size() == 1) { ExecutableElement candidate = constructors.get(0); - if (candidate.getParameters().size() > 0 && !env.hasAutowiredAnnotation(constructors.get(0))) { + if (candidate.getParameters().size() > 0 && !env.hasAutowiredAnnotation(candidate)) { if (type.getNestingKind() == NestingKind.MEMBER && candidate.getModifiers().contains(Modifier.PRIVATE)) { return null; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/aot.adoc b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/aot.adoc index c6c9e73f63..96dca8bf6d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/aot.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/aot.adoc @@ -38,6 +38,6 @@ The `nativeCompile` task of the GraalVM Native Image plugin is automatically con The AOT engine can be applied to JUnit 5 tests that use Spring's Test Context Framework. Suitable tests are processed by the `processTestAot` task to generate `ApplicationContextInitialzer` code. As with application AOT processing, the `BeanFactory` is fully prepared at build-time. -As with `processAot`, the `processTestAot` task is `JavaExec` sub-class and can be configured as needed to influence this processing. +As with `processAot`, the `processTestAot` task is `JavaExec` subclass and can be configured as needed to influence this processing. The `nativeTest` task of the GraalVM Native Image plugin is automatically configured to use the output of the `processAot` and `processTestAot` tasks. \ No newline at end of file diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java index 03dbf60f13..86e6e06a43 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java @@ -33,7 +33,7 @@ import org.xnio.XnioWorker; import org.springframework.util.Assert; /** - * A {@link HttpHandlerFactory} for an {@link AccessLogHandler}. + * An {@link HttpHandlerFactory} for an {@link AccessLogHandler}. * * @author Andy Wilkinson */ From d9a93a151412b6ca0b5bed1937ad6257c9e7e7b1 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 16 Nov 2022 10:00:50 +0100 Subject: [PATCH 2/2] Update copyright year of changed file See gh-33108 --- .../boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java index 86e6e06a43..c2520cbbfd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/AccessLogHttpHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 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.