Reject setups with multiple observation conventions

Prior to this commit, the `WebHttpHandlerBuilder` would only configure
a custom observation convention if there is a single convention in the
application context. It would other wise use the default.

This commit aligns with the previous Spring Boot behavior where multiple
conventions setups are rejected as invalid with
`NoUniqueBeanDefinitionException`.

Fixes gh-31864
This commit is contained in:
Brian Clozel
2023-12-19 17:35:02 +01:00
parent 12f01f9b5f
commit 53b937976d
2 changed files with 21 additions and 1 deletions

View File

@@ -198,7 +198,7 @@ public final class WebHttpHandlerBuilder {
.forEach(builder::httpHandlerDecorator);
context.getBeanProvider(ObservationRegistry.class).ifUnique(builder::observationRegistry);
context.getBeanProvider(ServerRequestObservationConvention.class).ifUnique(builder::observationConvention);
context.getBeanProvider(ServerRequestObservationConvention.class).ifAvailable(builder::observationConvention);
try {
builder.sessionManager(