Prior to this commit, the `HttpMessageConverters` auto-configuration
would pick up `HttpMessageConverter<?>` beans from the context and
broadly apply them to both server and client converters setup.
This can cause several types of problems.
First, specific configurations only meant for server setup will also be
applied to the client side. For example, the Actuator JSOn configuration
is only meant to be applied to the server infrastructure.
Also, picking up converters from the context does not convey whether
such converters are meant to override the default ones or should be
configured as custom, in addition to the defaults.
For example, a bean extending `JacksonJsonHttpMessageConverter` can be
both meant to override the default with `builder.withJsonConverter` or
meant as an additional converter with `builder.addCustomConverter`.
This commit ensures that the auto-configurations contribute
`ClientHttpMessageConvertersCustomizer` and
`ServerHttpMessageConvertersCustomizer` beans instead of converter beans
directly. Applications can still contribute such beans and those will be
used.
Fixes gh-48310
This commit adapts TestRestTemplate#getRootUri to the recently
introduced LocalTestWebServer. The behavior invokes the
UriTemplateHandler to provide the value. If the implementation expands
full URL, then it will provide the expected behavior. If not, it should
return the empty string as before.
Closes gh-48330
A change in Spring Security [1] means that type validation is now
performed by default by Spring Security. A breaking side-effect of
this is that setting validateTypes to false no longer has an effect
and the default JwtTypeValidator is still present. Its presence,
wrapped in a DelegatingOAuth2TokenValidator, prevents a user's
JwtTypeValidator bean from being used for type validation.
This commit updates Boot's auto-configuration to change how the
type validators are created. We avoid wrapping in a
DelegatingOAuth2TokenValidator so that the user's custom
JwtTypeValidator can be detected and used in place of the default.
This requires us to create the JwtIssuerValidator rather than using
the createDefaultWithIssuer method as it does not allow additional
validators to be provided.
Fixes gh-48301
[1] 6d3b54df21
Previously, HttpServiceClientAutoConfiguration used
NotReactiveWebApplicationCondition, which prevented
activation in reactive apps even when virtual threads
were enabled.
This commit removes the condition to follow suite with what was done in
gh-48308
See gh-48274
Signed-off-by: Nhahan <kisy324@naver.com>
Previously, the necessary infrastructure to create a RestClient was only
configured in a servlet-based application or in a reactive application
if virtual threads are enabled.
While this extra care was important in
Spring Boot 4 as the aut-configuration is always available, this is no
longer the case with Spring Boot 4. Indeed, an explicit module has to be
added to the classpath now.
This commit therefore relaxes the condition. If the module has been
added, then the infrastructure is auto-configured.
Closes gh-48308
Replace explicit casts with pattern variables to improve readability and
remove redundancy.
See gh-48297
Signed-off-by: geopark021 <geobrown021@gmail.com>
Starting from Spring Boot 4, the RestTemplateBuilder and
RestTemplateCustomizer classes have been moved from the
org.springframework.boot.web.client package to the
org.springframework.boot.restclient package. This commit updates
the javadoc links in the reference documentation to match
Signed-off-by: Antoine Rey <antoine.rey@free.fr>
See gh-48295
Previously, spring-boot-restclient was a required dependency of
spring-boot-resttestclient. This had the unwanted side-effect of
increasing the risk of the test classpath enabling auto-configuration
for RestClient.Builder when it was main code that needed such a bean.
This could lead to integration tests passing but the application
itself failing to start when its run through its main method.
This commit makes spring-boot-restclient an optional dependency of
spring-boot-resttestclient. As a result, a dependency on
spring-boot-resttestclient is no longer sufficient to auto-configure
a RestClient.Builder bean, although it is still sufficient to
auto-configure a RestTestClient bean.
Those that wish to use TestRestTemplate rather than migrating to
RestTestClient will now have to add a dependency on
spring-boot-restclient. This makes it presence more obvious. It now
has to be declared directly rather than being somewhat hidden due to
being pulled in transitively. The hope is that this will reduce the
chances of the dependency being accidentially on the test classpath
when main code requires it to be on the runtime classpath.
Fixes gh-48253