File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
module/spring-boot-jackson/src
main/java/org/springframework/boot/jackson/autoconfigure
test/java/org/springframework/boot/jackson/autoconfigure Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 2929import java .util .stream .Stream ;
3030
3131import com .fasterxml .jackson .annotation .JsonAutoDetect ;
32+ import com .fasterxml .jackson .annotation .JsonInclude .Include ;
3233import com .fasterxml .jackson .annotation .PropertyAccessor ;
3334import org .jspecify .annotations .Nullable ;
3435import tools .jackson .databind .JacksonModule ;
@@ -371,9 +372,10 @@ protected void customize(B builder) {
371372 if (this .jacksonProperties .isFindAndAddModules ()) {
372373 builder .findAndAddModules (getClass ().getClassLoader ());
373374 }
374- if (this .jacksonProperties .getDefaultPropertyInclusion () != null ) {
375- builder .changeDefaultPropertyInclusion (
376- (handler ) -> handler .withValueInclusion (this .jacksonProperties .getDefaultPropertyInclusion ()));
375+ Include propertyInclusion = this .jacksonProperties .getDefaultPropertyInclusion ();
376+ if (propertyInclusion != null ) {
377+ builder .changeDefaultPropertyInclusion ((handler ) -> handler .withValueInclusion (propertyInclusion )
378+ .withContentInclusion (propertyInclusion ));
377379 }
378380 if (this .jacksonProperties .getTimeZone () != null ) {
379381 builder .defaultTimeZone (this .jacksonProperties .getTimeZone ());
Original file line number Diff line number Diff line change @@ -436,19 +436,23 @@ void customModulesRegisteredByXmlMapperBuilderCustomizerShouldBeRetained() {
436436
437437 @ EnumSource
438438 @ ParameterizedTest
439- void defaultSerializationInclusion (MapperType mapperType ) {
439+ void defaultPropertyInclusion (MapperType mapperType ) {
440440 this .contextRunner .run ((context ) -> {
441441 ObjectMapper mapper = mapperType .getMapper (context );
442+ assertThat (mapper .serializationConfig ().getDefaultPropertyInclusion ().getContentInclusion ())
443+ .isEqualTo (JsonInclude .Include .USE_DEFAULTS );
442444 assertThat (mapper .serializationConfig ().getDefaultPropertyInclusion ().getValueInclusion ())
443445 .isEqualTo (JsonInclude .Include .USE_DEFAULTS );
444446 });
445447 }
446448
447449 @ EnumSource
448450 @ ParameterizedTest
449- void customSerializationInclusion (MapperType mapperType ) {
451+ void customPropertyInclusion (MapperType mapperType ) {
450452 this .contextRunner .withPropertyValues ("spring.jackson.default-property-inclusion:non_null" ).run ((context ) -> {
451453 ObjectMapper mapper = mapperType .getMapper (context );
454+ assertThat (mapper .serializationConfig ().getDefaultPropertyInclusion ().getContentInclusion ())
455+ .isEqualTo (JsonInclude .Include .NON_NULL );
452456 assertThat (mapper .serializationConfig ().getDefaultPropertyInclusion ().getValueInclusion ())
453457 .isEqualTo (JsonInclude .Include .NON_NULL );
454458 });
You can’t perform that action at this time.
0 commit comments