Skip to content

Commit cd3daa8

Browse files
committed
Merge branch '6.0.x'
2 parents 8064659 + 5f05340 commit cd3daa8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.fasterxml.jackson.databind.ObjectMapper;
4646
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
4747
import com.fasterxml.jackson.databind.SerializationFeature;
48+
import com.fasterxml.jackson.databind.cfg.DatatypeFeature;
4849
import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
4950
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair;
5051
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
@@ -839,6 +840,9 @@ else if (feature instanceof SerializationFeature serializationFeature) {
839840
else if (feature instanceof DeserializationFeature deserializationFeature) {
840841
objectMapper.configure(deserializationFeature, enabled);
841842
}
843+
else if (feature instanceof DatatypeFeature datatypeFeature) {
844+
objectMapper.configure(datatypeFeature, enabled);
845+
}
842846
else if (feature instanceof MapperFeature mapperFeature) {
843847
objectMapper.configure(mapperFeature, enabled);
844848
}

spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import com.fasterxml.jackson.databind.SerializerProvider;
5858
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
5959
import com.fasterxml.jackson.databind.cfg.DeserializerFactoryConfig;
60+
import com.fasterxml.jackson.databind.cfg.EnumFeature;
61+
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;
6062
import com.fasterxml.jackson.databind.cfg.SerializerFactoryConfig;
6163
import com.fasterxml.jackson.databind.deser.BasicDeserializerFactory;
6264
import com.fasterxml.jackson.databind.deser.Deserializers;
@@ -478,10 +480,12 @@ void completeSetup() throws JsonMappingException {
478480
.annotationIntrospector(current -> AnnotationIntrospector.pair(current, introspector))
479481
.featuresToEnable(SerializationFeature.FAIL_ON_EMPTY_BEANS,
480482
DeserializationFeature.UNWRAP_ROOT_VALUE,
483+
EnumFeature.WRITE_ENUMS_TO_LOWERCASE,
481484
JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER,
482485
JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS)
483486
.featuresToDisable(MapperFeature.AUTO_DETECT_GETTERS,
484487
MapperFeature.AUTO_DETECT_FIELDS,
488+
JsonNodeFeature.READ_NULL_PROPERTIES,
485489
JsonParser.Feature.AUTO_CLOSE_SOURCE,
486490
JsonGenerator.Feature.QUOTE_FIELD_NAMES)
487491
.serializationInclusion(JsonInclude.Include.NON_NULL);
@@ -510,13 +514,15 @@ void completeSetup() throws JsonMappingException {
510514

511515
assertThat(mapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)).isTrue();
512516
assertThat(mapper.getDeserializationConfig().isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE)).isTrue();
517+
assertThat(mapper.getSerializationConfig().isEnabled(EnumFeature.WRITE_ENUMS_TO_LOWERCASE)).isTrue();
513518
assertThat(mapper.getFactory().isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)).isTrue();
514519
assertThat(mapper.getFactory().isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS)).isTrue();
515520

516521
assertThat(mapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS)).isFalse();
517522
assertThat(mapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)).isFalse();
518523
assertThat(mapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
519524
assertThat(mapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS)).isFalse();
525+
assertThat(mapper.getDeserializationConfig().isEnabled(JsonNodeFeature.READ_NULL_PROPERTIES)).isFalse();
520526
assertThat(mapper.getFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE)).isFalse();
521527
assertThat(mapper.getFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES)).isFalse();
522528
assertThat(mapper.getSerializationConfig().getSerializationInclusion()).isSameAs(JsonInclude.Include.NON_NULL);

0 commit comments

Comments
 (0)