Fix #5742: prevent @JsonSetter(contentNulls) propagation into nested containers#5751
Open
dlwldnjs1009 wants to merge 2 commits intoFasterXML:3.xfrom
Open
Fix #5742: prevent @JsonSetter(contentNulls) propagation into nested containers#5751dlwldnjs1009 wants to merge 2 commits intoFasterXML:3.xfrom
dlwldnjs1009 wants to merge 2 commits intoFasterXML:3.xfrom
Conversation
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@JsonSetter(contentNulls = Nulls.FAIL)on nested container properties such asList<List<String>>incorrectly rejects[[null]]. Only[null](nullimmediate content of the annotated container) should be rejected.
The root cause is that container deserializers pass the same
BeanPropertyintonested content deserializer contextualization, so deeper container levels read
the outer property's annotation-level
contentNulls.Changes
_contentProperty()inStdDeserializerto create a derivedBeanPropertyview for nested content contextualization that strips only theouter property's explicit annotation-level
contentNulls.contentNullsfrom the nested content type'sConfigOverrideor global default._ContentBeanProperty, a lightweight delegating wrapper that preserves theoriginal property identity (name/member/type) and overrides only metadata
relevant to nested content-null handling.
and closely related nested-container cases:
CollectionDeserializer,MapDeserializer,EnumMapDeserializer, andObjectArrayDeserializer.Properties without explicit
@JsonSetter(contentNulls=...)retain existingbehavior, including ConfigOverride-only and global-default-only cases.
Scope & Known Gaps
This fix is intentionally scoped to the container deserializer paths involved in
the reported issue and closely related nested-container cases.
ReferenceTypeDeserializer(used byOptional,AtomicReference) andMapEntryDeserializerfollow the same general pattern, but are left forfollow-up to keep this PR focused on #5742.
Test plan
recordnestedListtestsMap<String, List<String>>,EnumMap, andString[][]./mvnw clean verifypasses