Merge branch '4.0.x'

Closes gh-49250
This commit is contained in:
Phillip Webb
2026-02-17 22:27:01 -08:00
10 changed files with 165 additions and 2 deletions
@@ -33,7 +33,6 @@ class DefaultClientHttpMessageConvertersCustomizer implements ClientHttpMessageC
DefaultClientHttpMessageConvertersCustomizer(@Nullable HttpMessageConverters legacyConverters,
Collection<HttpMessageConverter<?>> converters) {
this.legacyConverters = legacyConverters;
this.converters = converters;
}
@@ -29,6 +29,7 @@ import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.HttpClientSettings;
import org.springframework.boot.http.client.autoconfigure.imperative.ImperativeHttpClientAutoConfiguration;
import org.springframework.boot.http.converter.autoconfigure.ClientHttpMessageConvertersCustomizer;
import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.restclient.RestClientCustomizer;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.context.annotation.Bean;
@@ -54,7 +55,7 @@ import org.springframework.web.client.RestClient.Builder;
* @since 4.0.0
*/
@AutoConfiguration(after = { ImperativeHttpClientAutoConfiguration.class, TaskExecutionAutoConfiguration.class,
SslAutoConfiguration.class })
SslAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class })
@ConditionalOnClass(RestClient.class)
public final class RestClientAutoConfiguration {
+1
View File
@@ -438,6 +438,7 @@ include ":smoke-test:spring-boot-smoke-test-pulsar"
include ":smoke-test:spring-boot-smoke-test-quartz"
include ":smoke-test:spring-boot-smoke-test-reactive-oauth2-client"
include ":smoke-test:spring-boot-smoke-test-reactive-oauth2-resource-server"
include ":smoke-test:spring-boot-smoke-test-restclient"
include ":smoke-test:spring-boot-smoke-test-rsocket"
include ":smoke-test:spring-boot-smoke-test-saml2-service-provider"
include ":smoke-test:spring-boot-smoke-test-secure"
@@ -0,0 +1,31 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id "java"
}
description = "Spring Boot Rest Client smoke test"
dependencies {
implementation(project(":starter:spring-boot-starter-restclient"))
testImplementation(project(":starter:spring-boot-starter-test"))
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
@@ -0,0 +1,11 @@
package aaaa;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@AutoConfiguration(afterName = { "org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration",
"org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration" })
class Gh49223AutoConfiguration {
// Class must be in a package name that is ordered early
}
@@ -0,0 +1,20 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NullMarked
package aaaa;
import org.jspecify.annotations.NullMarked;
@@ -0,0 +1,29 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package smoketest.restclient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SampleRestClientApplication {
public static void main(String[] args) {
SpringApplication.run(SampleRestClientApplication.class, args);
}
}
@@ -0,0 +1,20 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NullMarked
package smoketest.restclient;
import org.jspecify.annotations.NullMarked;
@@ -0,0 +1,50 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package smoketest.restclient;
import java.util.List;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.DeserializationFeature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.client.RestClient;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(properties = "spring.jackson.deserialization.fail-on-null-for-primitives=false")
class SampleRestClientApplicationGh49223Tests {
@Autowired
private RestClient.Builder restClientBuilder;
@Test
void applicationStarts() {
RestClient restClient = this.restClientBuilder.build();
List<?> messageConverters = (List<?>) ReflectionTestUtils.getField(restClient, "messageConverters");
JacksonJsonHttpMessageConverter jacksonConverter = (JacksonJsonHttpMessageConverter) messageConverters.stream()
.filter((converter) -> converter instanceof JacksonJsonHttpMessageConverter)
.findFirst()
.orElseThrow();
assertThat(jacksonConverter.getMapper().isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES))
.isFalse();
}
}