From 3b2a16b96ae8022d6e2064cab81af47a4bdd862d Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 22 Jul 2025 23:34:19 +0900 Subject: [PATCH 1/3] Polish Signed-off-by: Johnny Lim --- .../bind/CollectionBinderTests.java | 32 +++++++++---------- .../pages/features/external-config.adoc | 2 +- .../RabbitTemplateConfigurer.java | 2 +- .../HttpMessageConvertersProperties.java | 2 +- .../ObservationHandlerGroup.java | 2 +- .../ObservationHandlerGroups.java | 2 +- ...racingAndMeterObservationHandlerGroup.java | 2 +- ...ationsOpenTelemetryConfigurationTests.java | 11 ++++--- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java b/core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java index 3b8d79c44063..0638d6f00350 100644 --- a/core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java +++ b/core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java @@ -119,10 +119,10 @@ void bindToCollectionWhenNonSequentialShouldThrowException() { .satisfies((ex) -> { Set unbound = ((UnboundConfigurationPropertiesException) ex.getCause()) .getUnboundProperties(); - assertThat(unbound).hasSize(1); - ConfigurationProperty property = unbound.iterator().next(); - assertThat(property.getName()).hasToString("foo[3]"); - assertThat(property.getValue()).isEqualTo("3"); + assertThat(unbound).singleElement().satisfies((property) -> { + assertThat(property.getName()).hasToString("foo[3]"); + assertThat(property.getValue()).isEqualTo("3"); + }); }); } @@ -139,10 +139,10 @@ void bindToCollectionWhenNonKnownIndexedChildNotBoundThrowsException() { .satisfies((ex) -> { Set unbound = ((UnboundConfigurationPropertiesException) ex.getCause()) .getUnboundProperties(); - assertThat(unbound).hasSize(1); - ConfigurationProperty property = unbound.iterator().next(); - assertThat(property.getName()).hasToString("foo[1].missing"); - assertThat(property.getValue()).isEqualTo("bad"); + assertThat(unbound).singleElement().satisfies((property) -> { + assertThat(property.getName()).hasToString("foo[1].missing"); + assertThat(property.getValue()).isEqualTo("bad"); + }); }); } @@ -155,10 +155,10 @@ void bindToNestedCollectionWhenNonKnownIndexed() { source.put("foo[0].string", "test"); this.sources.add(source); List list = this.binder.bind("foo", Bindable.listOf(ExampleCollectionBean.class)).get(); - assertThat(list).hasSize(1); - ExampleCollectionBean bean = list.get(0); - assertThat(bean.getItems()).containsExactly("a", "b", "d"); - assertThat(bean.getString()).isEqualTo("test"); + assertThat(list).singleElement().satisfies((bean) -> { + assertThat(bean.getItems()).containsExactly("a", "b", "d"); + assertThat(bean.getString()).isEqualTo("test"); + }); } @Test @@ -173,10 +173,10 @@ void bindToNonScalarCollectionWhenNonSequentialShouldThrowException() { .satisfies((ex) -> { Set unbound = ((UnboundConfigurationPropertiesException) ex.getCause()) .getUnboundProperties(); - assertThat(unbound).hasSize(1); - ConfigurationProperty property = unbound.iterator().next(); - assertThat(property.getName()).hasToString("foo[4].value"); - assertThat(property.getValue()).isEqualTo("4"); + assertThat(unbound).singleElement().satisfies((property) -> { + assertThat(property.getName()).hasToString("foo[4].value"); + assertThat(property.getValue()).isEqualTo("4"); + }); }); } diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc index 95edc9c3948d..6ff140a50803 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc @@ -1173,7 +1173,7 @@ Beans used for property conversion are requested very early during the applicati Typically, any dependency that you require may not be fully initialized at creation time. ==== -TIP: You may want to rename your custom javadoc:org.springframework.core.convert.ConversionService[] if it is not required for configuration keys coercion and only rely on custom converters qualified with javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesBinding[format=annotation]. +TIP: You may want to rename your custom javadoc:org.springframework.core.convert.ConversionService[] if it is not required for configuration keys coercion and only relies on custom converters qualified with javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesBinding[format=annotation]. When qualifying a `@Bean` method with `@ConfigurationPropertiesBinding`, the method should be `static` to avoid "`bean is not eligible for getting processed by all BeanPostProcessors`" warnings. diff --git a/module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/autoconfigure/RabbitTemplateConfigurer.java b/module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/autoconfigure/RabbitTemplateConfigurer.java index 2273e1d85859..a8af90eba1a0 100644 --- a/module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/autoconfigure/RabbitTemplateConfigurer.java +++ b/module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/autoconfigure/RabbitTemplateConfigurer.java @@ -33,7 +33,7 @@ * properties. *

* Can be injected into application code and used to define a custom - * {@code RabbitTemplateConfigurer} whose configuration is based upon that produced by + * {@code RabbitTemplate} whose configuration is based upon that produced by * auto-configuration. * * @author Stephane Nicoll diff --git a/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/HttpMessageConvertersProperties.java b/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/HttpMessageConvertersProperties.java index fb141e1fec32..47ffe28c21ff 100644 --- a/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/HttpMessageConvertersProperties.java +++ b/module/spring-boot-http-converter/src/main/java/org/springframework/boot/http/converter/autoconfigure/HttpMessageConvertersProperties.java @@ -31,7 +31,7 @@ public class HttpMessageConvertersProperties { /** - * The charset to use for String conversion. + * Charset to use for String conversion. */ private Charset stringEncodingCharset = StandardCharsets.UTF_8; diff --git a/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroup.java b/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroup.java index fb318c0ca449..85a86639d14b 100644 --- a/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroup.java +++ b/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroup.java @@ -65,7 +65,7 @@ default int compareTo(ObservationHandlerGroup other) { Class handlerType(); /** - * Static factory method to create a {@link ObservationHandlerGroup} with members of + * Static factory method to create an {@link ObservationHandlerGroup} with members of * the given handler type. * @param the handler type * @param handlerType the handler type diff --git a/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroups.java b/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroups.java index 688dc705e889..5bf93b999d5a 100644 --- a/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroups.java +++ b/module/spring-boot-observation/src/main/java/org/springframework/boot/observation/autoconfigure/ObservationHandlerGroups.java @@ -29,7 +29,7 @@ import org.springframework.util.MultiValueMap; /** - * A collection {@link ObservationHandlerGroup} instance and supporting registration + * A collection of {@link ObservationHandlerGroup} instances and supporting registration * logic. * * @author Andy Wilkinson diff --git a/module/spring-boot-tracing/src/main/java/org/springframework/boot/tracing/autoconfigure/TracingAndMeterObservationHandlerGroup.java b/module/spring-boot-tracing/src/main/java/org/springframework/boot/tracing/autoconfigure/TracingAndMeterObservationHandlerGroup.java index f475f66ed202..57276a6b9edc 100644 --- a/module/spring-boot-tracing/src/main/java/org/springframework/boot/tracing/autoconfigure/TracingAndMeterObservationHandlerGroup.java +++ b/module/spring-boot-tracing/src/main/java/org/springframework/boot/tracing/autoconfigure/TracingAndMeterObservationHandlerGroup.java @@ -32,7 +32,7 @@ /** * {@link ObservationHandlerGroup} that considers both {@link TracingObservationHandler} * and {@link MeterObservationHandler} types as members. This group takes precedence over - * any regular {@link MeterObservationHandler} group in order to use ensure + * any regular {@link MeterObservationHandler} group in order to ensure * {@link TracingAwareMeterObservationHandler} wrapping is applied during registration. * * @author Phillip Webb diff --git a/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java b/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java index c90698e3a0af..5a2a8f0040b2 100644 --- a/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java +++ b/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java @@ -44,11 +44,12 @@ class ZipkinConfigurationsOpenTelemetryConfigurationTests { @Test void backsOffWithoutEncoding() { - new ApplicationContextRunner().withUserConfiguration(OpenTelemetryConfiguration.class).run((context) -> { - assertThat(context).hasNotFailed(); - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).doesNotHaveBean(BytesEncoder.class); - }); + new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(OpenTelemetryConfiguration.class)) + .run((context) -> { + assertThat(context).hasNotFailed(); + assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); + assertThat(context).doesNotHaveBean(BytesEncoder.class); + }); } @Test From 32c9bbe78eefe4eb99b913b7890a220e355b3447 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 23 Jul 2025 07:20:24 +0900 Subject: [PATCH 2/3] Revert incorrect change See https://github.com/spring-projects/spring-boot/pull/46505#discussion_r2223342335 Signed-off-by: Johnny Lim --- .../modules/reference/pages/features/external-config.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc index 6ff140a50803..95edc9c3948d 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc @@ -1173,7 +1173,7 @@ Beans used for property conversion are requested very early during the applicati Typically, any dependency that you require may not be fully initialized at creation time. ==== -TIP: You may want to rename your custom javadoc:org.springframework.core.convert.ConversionService[] if it is not required for configuration keys coercion and only relies on custom converters qualified with javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesBinding[format=annotation]. +TIP: You may want to rename your custom javadoc:org.springframework.core.convert.ConversionService[] if it is not required for configuration keys coercion and only rely on custom converters qualified with javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesBinding[format=annotation]. When qualifying a `@Bean` method with `@ConfigurationPropertiesBinding`, the method should be `static` to avoid "`bean is not eligible for getting processed by all BeanPostProcessors`" warnings. From 00e2d1b11c44e6c390b69d69b34c5488d823afde Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Wed, 23 Jul 2025 22:18:22 +0900 Subject: [PATCH 3/3] Revert AutoConfigurations.of() change See https://github.com/spring-projects/spring-boot/pull/46505/files#r2224467888 Signed-off-by: Johnny Lim --- ...ConfigurationsOpenTelemetryConfigurationTests.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java b/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java index 5a2a8f0040b2..c90698e3a0af 100644 --- a/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java +++ b/module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/zipkin/ZipkinConfigurationsOpenTelemetryConfigurationTests.java @@ -44,12 +44,11 @@ class ZipkinConfigurationsOpenTelemetryConfigurationTests { @Test void backsOffWithoutEncoding() { - new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(OpenTelemetryConfiguration.class)) - .run((context) -> { - assertThat(context).hasNotFailed(); - assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); - assertThat(context).doesNotHaveBean(BytesEncoder.class); - }); + new ApplicationContextRunner().withUserConfiguration(OpenTelemetryConfiguration.class).run((context) -> { + assertThat(context).hasNotFailed(); + assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class); + assertThat(context).doesNotHaveBean(BytesEncoder.class); + }); } @Test