mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-11 04:04:07 +00:00
Fix Jackson3 class reference in condition
Prior to this commit, the `XmlMapper` auto-configuration for Jackson2 would refer to Jackson3's `XmlMapper` instead of Jackson2. This would not only make the condition invalid, but it could also lead to `NoClassDefFoundError` at runtime if the application mixed Jackson 2 and 3 on the classpath. Fixes gh-49015
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
||||
package org.springframework.boot.http.converter.autoconfigure;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import tools.jackson.dataformat.xml.XmlMapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
|
||||
+24
-1
@@ -187,7 +187,7 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
@Test
|
||||
@Deprecated(since = "4.0.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
void jackson2ServerAndClientConvertersShouldBeDifferent() {
|
||||
void jackson2ServerAndClientJsonConvertersShouldBeDifferent() {
|
||||
this.contextRunner.withUserConfiguration(Jackson2ObjectMapperConfig.class)
|
||||
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
|
||||
.run((context) -> {
|
||||
@@ -201,6 +201,23 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated(since = "4.0.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
void jackson2ServerAndClientXmlConvertersShouldBeDifferent() {
|
||||
this.contextRunner.withUserConfiguration(Jackson2ObjectMapperConfig.class)
|
||||
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(
|
||||
Jackson2HttpMessageConvertersConfiguration.Jackson2XmlMessageConvertersCustomizer.class);
|
||||
HttpMessageConverter<?> serverConverter = findConverter(getServerConverters(context),
|
||||
org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter.class);
|
||||
HttpMessageConverter<?> clientConverter = findConverter(getClientConverters(context),
|
||||
org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter.class);
|
||||
assertThat(serverConverter).isNotEqualTo(clientConverter);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void gsonNotAvailable() {
|
||||
this.contextRunner.run((context) -> {
|
||||
@@ -579,8 +596,14 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@SuppressWarnings("removal")
|
||||
static class Jackson2ObjectMapperConfig {
|
||||
|
||||
@Bean
|
||||
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder objectMapperBuilder() {
|
||||
return new org.springframework.http.converter.json.Jackson2ObjectMapperBuilder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ObjectMapper objectMapper() {
|
||||
return new ObjectMapper();
|
||||
|
||||
Reference in New Issue
Block a user