Fix #6136: honor @JsonFilter for @JsonAnyGetter entries - #6134
Fix #6136: honor @JsonFilter for @JsonAnyGetter entries#6134aysha-afrah26 wants to merge 9 commits into
@JsonFilter for @JsonAnyGetter entries#6134Conversation
|
I think we should have separate issue explaining specific usage, problem, and then this PR can refer to it. And no, I don't think this should be backported; 3.x is fine. |
@JsonFilter for @JsonAnyGetter entries@JsonFilter for @JsonAnyGetter entries
|
Makes sense. Filed #6136 with the specific usage and reproduction, and updated the PR title/body and test comments to reference it. Agreed on keeping this to 3.x, no backport. |
|
Ok this will take a while to review, so many issues flagged by LLM (Claude) review. |
|
Good call moving the unpacking into BeanSerializerBase. Handling it caller-side covers direct PropertyFilter implementations too, which my filter-side version missed. If it helps, feel free to post whatever else got flagged and I'm happy to work through the list. |
|
Caught up on your commits. Moving the unpacking into |
Code Review ✅ ApprovedUpdates AnyGetterWriter to route entries through 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 |
Fixes #6136 (see the issue for usage details and reproduction).
Short version:
SimpleBeanPropertyFilter.serializeAsProperty()runsinclude()against the name of the any-getter accessor rather than the names of the entries it emits, so an exclude filter (serializeAllExcept()) lets the writer straight through togetAndSerialize()and every entry goes out, including excluded ones. OnlyfilterOutAllExceptreaches the per-entrygetAndFilter(), since that call sits in theelsebranch. The fix routesAnyGetterWritertogetAndFilter()before theinclude()check, so inclusion is decided per entry.A
JsonNode-valued any-getter ([databind#3604]) leaks the same way under either filter style, becausegetAndFilter()short-circuits those to unfiltered entries; they now go throughMapPropertythe way map entries already do. Sending every any-getter downgetAndFilter()also exposed its hardcodednullsuppressable value, which droppedNON_EMPTYon the filtered path, so it now uses the one itsMapSerializerwas built with.Targets
3.xonly, per discussion below.