Conversation
Views declared on an any-setter were ignored on deserialization, so values were passed to it regardless of the active view -- unlike regular properties, and unlike `@JsonAnyGetter` on serialization. Now, if the any-setter is not visible in the active view, the value is skipped (or, with `DeserializationFeature.FAIL_ON_UNEXPECTED_VIEW_PROPERTIES`, reported), same as for regular properties. Only an explicit `@JsonView` on the any-setter itself is considered; class-level default views are not applied, so un-annotated any-setters behave as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved🟡 Medium risk · Changes view-based filtering for unmatched properties across multiple deserialization paths Adds support for honoring OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
This branch has not been deployed
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.
@JsonViewon a@JsonAnySetterwas ignored when deserializing: values for unmatched properties were passed to the any-setter no matter which view was active. Regular properties already honor views, and so does@JsonAnyGetterwhen serializing.Changes
SettableAnyPropertynow stores views (setViews(),visibleInView(),hasViews()), andwithValueDeserializer()carries them over.BeanDeserializerFactoryreads an explicit@JsonViewfrom the any-setter accessor. This works for methods, fields and creator parameters.BeanDeserializerBuilder._anyViews()enables view processing when the any-setter has views.BeanDeserializerBase._skipIfAnySetterNotInView(), called at every point where a value goes to the any-setter: the vanilla, creator, record-update, unwrapped and external-type-id paths,BuilderBasedDeserializer, andThrowableDeserializer. A hidden value is skipped. IfFAIL_ON_UNEXPECTED_VIEW_PROPERTIESis enabled, it is reported instead, the same way as for regular properties.Tradeoff
Only an explicit
@JsonViewon the any-setter counts. Class-level default views andDEFAULT_VIEW_INCLUSIONare not applied to it. That differs from regular properties and from@JsonAnyGetter. Applying them would mean that with 3.x defaults (DEFAULT_VIEW_INCLUSIONdisabled), an un-annotated any-setter stops receiving any values once a view is active. That seemed too big a behavior change for a patch release. If full symmetry is wanted, it could be done in 3.3.Tests
Added
AnySetterViewDeserializationTest, which covers method, field, creator-bean, record creator-parameter and builder any-setters, an un-annotated any-setter (behavior unchanged), andFAIL_ON_UNEXPECTED_VIEW_PROPERTIES. Without the fix, 6 of its 7 tests fail../mvnw verifypasses.🤖 Generated with Claude Code