Adds a management.observations.conventions property to control which
set of conventions are auto-configured across the application.
Configures WebMvc and WebFlux ServerRequestObservationConvention
beans to switch to OpenTelemetry conventions when configured.
Configures JVM and system meter binders using their builder APIs to
apply OpenTelemetry conventions while still allowing individual
meter conventions to be overridden via beans.
Signed-off-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com>
See gh-49241
Prior to this commit, Spring Boot would auto-configure the
`ForwardedHeaderFilter`/`ForwardedHeaderTransformer` when the "NATIVE"
strategy is chosen.
Spring Framework now requires an explicit choice between the supported
HTTP header variants as of spring-projects/spring-framework#37072.
This commit adapts to this new behavior with the following:
* the "FRAMEWORK" strategy now only applies to Spring MVC and Spring
WebFlux applications, since "NATIVE" strategies are now a good choice
for most deployments.
* the format of HTTP headers is now configured with
`spring.mvc.forwarded-headers.header-format` and
`spring.webflux.forwarded-headers.header-format`, with additional
options.
The default header format is now "X-Forwarded-*" for both NATIVE and
FRAMEWORK strategies. The reference documentation also reflects those
changes.
Closes gh-51030
This commit adapts the auto-configuration for API versioning to apply
the path segment last as this strategy is not meant to yield. It also
clarifies that configuration properties should not be used if ordering
of the strategies is important.
Closes gh-49800
Following modularization, a presence check for ValidatorAdapter was
needed in the MVC and WebFlux auto-configuratiomn when creating
their Validators. Runtime hints to allow this check to work in a
native image were not added at the same time, resulting in the
class appearing to be absent. This caused message interpolation
for constraint violations to fail as newly created Validator was
being used which lacked the necessary MessageInterpolator
configuration.
This commit adds reflection hints for ValidatorAdapter, allowing
re-use of the context's main validator as the MVC and WebFlux
validators.
Fixes gh-48828
Introduce a strategy to `WebApplicationType` to allow modules to
implement deduction logic.
Prior to this commit, modules played no part in deducing the
`WebApplicationType`. This meant that a user with `spring-webflux`
for client purposes would deduce `REACTIVE` despite no
`spring-boot-webflux` module being present.
The following deduction logic order is now implemented:
1) If the `spring-boot-webmvc` module is being used and Spring MVC
classes are found then `SERVLET` is used.
2) If the `spring-boot-webflux` module is being used and Spring WebFlux
classes are found then `REACTIVE` is used.
3) If `spring-web` is found and servlet classes are available then
`SERVLET` is used.
4) If none of the above are satisfied, `NONE` is used.
This commit also updates `SpringBootTestContextBootstrapper` to use
the same deduction logic.
Fixes gh-48517
Mirror the package names used in actuator for classes to support
mappings and exchanges in `spring-boot-servlet`, `spring-boot-webmvc`
and `spring-boot-webflux`.
Closes gh-46217
This commit modularizes spring-boot-test-autoconfigure. It now
contains only the code that's central to test auto-configuration.
Feature-specific functionality has moved out into -test modules,
some existing and some newly created. For example, `@DataJpaTest` can
now be found in spring-boot-data-jpa-test.
Closes gh-47322
Refactor `PropertyMapper` so that it no longer calls adapter or
predicate methods by default when the source value is `null`. This
effectively makes all default calls the same as using
`alwaysWhenNotNull` in the previous generation of the code.
For the limited times when you do need to deal with `null` values, the
new `always()` method can be used.
For example,
map.from(source::method).to(destination::method);
Will not call `destination.method(...)` if `source.method()` returns
`null`.
Where as:
map.from(source::method).always().to(destination::method);
Will call `destination.method(null)` if `source.method()` returns
`null`.
This update provides clearer semantics for the API and allows for better
JSpecify nullability annotations. It has also simplified much of our
existing property mapper code.
Closes gh-47024
Co-authored-by: Moritz Halbritter <moritz.halbritter@broadcom.com>