Skip to content
Closed

Polish #46505

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ void bindToCollectionWhenNonSequentialShouldThrowException() {
.satisfies((ex) -> {
Set<ConfigurationProperty> 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");
});
});
}

Expand All @@ -139,10 +139,10 @@ void bindToCollectionWhenNonKnownIndexedChildNotBoundThrowsException() {
.satisfies((ex) -> {
Set<ConfigurationProperty> 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");
});
});
}

Expand All @@ -155,10 +155,10 @@ void bindToNestedCollectionWhenNonKnownIndexed() {
source.put("foo[0].string", "test");
this.sources.add(source);
List<ExampleCollectionBean> 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
Expand All @@ -173,10 +173,10 @@ void bindToNonScalarCollectionWhenNonSequentialShouldThrowException() {
.satisfies((ex) -> {
Set<ConfigurationProperty> 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");
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "rely" is correct here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wilkinsona Thanks for the feedback!

I reverted it in 32c9bbe.

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.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* properties.
* <p>
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <H> the handler type
* @param handlerType the handler type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Member

@wilkinsona wilkinsona Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetryConfiguration isn't an @AutoConfiguration so this is fine as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wilkinsona I don't know exactly what it does behind the scenes, but I saw the following code in the same class, so I thought that a part of the auto-configuration also uses AutoConfigurations.of():

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(DefaultEncodingConfiguration.class, OpenTelemetryConfiguration.class));

There are more occurrences like this, for example, as follows:

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(PulsarConfiguration.class))
.withBean(PulsarClient.class, () -> mock(PulsarClient.class));

I also thought that "User" in the withUserConfiguration() doesn't sound right for a part of the auto-configuration.

Are you suggesting that the mixed uses are okay, or that they need to be used with the withUserConfiguration() if it's not an @AutoConfiguration?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoConfigurations.of does two things:

  1. It sorts all of the passed-in configurations based on their before and after attributes
  2. It orders the configurations so that they're processed before any user configurations

In this case, the configuration isn't an auto-configuration so there are no before and after attributes to consider and there's only of them so there's nothing to sort. There's also only one configuration class in the test so the order in which they're processed doesn't matter either.

We're pretty inconsistent about this across our tests. What was there before is fine and what you've proposed is also fine. Given this, I'd prefer to leave things as they were.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wilkinsona Thanks for the explanation!

I reverted it in 00e2d1b.

.run((context) -> {
assertThat(context).hasNotFailed();
assertThat(context).doesNotHaveBean(ZipkinSpanExporter.class);
assertThat(context).doesNotHaveBean(BytesEncoder.class);
});
}

@Test
Expand Down