Skip to content

Fix #6136: honor @JsonFilter for @JsonAnyGetter entries - #6134

Open
aysha-afrah26 wants to merge 9 commits into
FasterXML:3.xfrom
aysha-afrah26:jsonfilter-any-getter
Open

Fix #6136: honor @JsonFilter for @JsonAnyGetter entries#6134
aysha-afrah26 wants to merge 9 commits into
FasterXML:3.xfrom
aysha-afrah26:jsonfilter-any-getter

Conversation

@aysha-afrah26

@aysha-afrah26 aysha-afrah26 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #6136 (see the issue for usage details and reproduction).

Short version: SimpleBeanPropertyFilter.serializeAsProperty() runs include() 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 to getAndSerialize() and every entry goes out, including excluded ones. Only filterOutAllExcept reaches the per-entry getAndFilter(), since that call sits in the else branch. The fix routes AnyGetterWriter to getAndFilter() before the include() check, so inclusion is decided per entry.

A JsonNode-valued any-getter ([databind#3604]) leaks the same way under either filter style, because getAndFilter() short-circuits those to unfiltered entries; they now go through MapProperty the way map entries already do. Sending every any-getter down getAndFilter() also exposed its hardcoded null suppressable value, which dropped NON_EMPTY on the filtered path, so it now uses the one its MapSerializer was built with.

Targets 3.x only, per discussion below.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.86% 📈 +0.010%
Branches branches 75.49% 📈 +0.030%

Coverage data generated from JaCoCo test results

@cowtowncoder

cowtowncoder commented Jul 29, 2026

Copy link
Copy Markdown
Member

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.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.50% 📈 +0.040%

Coverage data generated from JaCoCo test results

@aysha-afrah26 aysha-afrah26 changed the title Honor @JsonFilter for @JsonAnyGetter entries Fix #6136: honor @JsonFilter for @JsonAnyGetter entries Jul 30, 2026
@aysha-afrah26

Copy link
Copy Markdown
Contributor Author

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.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.49% 📈 +0.030%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.49% 📈 +0.040%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.49% 📈 +0.040%

Coverage data generated from JaCoCo test results

@cowtowncoder

cowtowncoder commented Aug 4, 2026

Copy link
Copy Markdown
Member

Ok this will take a while to review, so many issues flagged by LLM (Claude) review.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.50% 📈 +0.050%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.50% 📈 +0.050%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.87% 📈 +0.020%
Branches branches 75.50% 📈 +0.050%

Coverage data generated from JaCoCo test results

@aysha-afrah26

Copy link
Copy Markdown
Contributor Author

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.

@aysha-afrah26

Copy link
Copy Markdown
Contributor Author

Caught up on your commits. Moving the unpacking into BeanSerializerBase is better than what I had, since custom PropertyFilter implementations get per-entry decisions too, and the unwrapping serializer picks it up for free through _serializePropertiesFiltered. Pulled the branch and reran the full suite locally, 6187 tests green. Nothing outstanding from my side.

@gitar-bot

gitar-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Updates AnyGetterWriter to route entries through getAndFilter() for proper per-entry JSON filter evaluation and resolves JsonNode-valued leakages. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.94% 📈 +0.020%
Branches branches 75.60% 📈 +0.040%

Coverage data generated from JaCoCo test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@JsonFilter with serializeAllExcept() does not filter @JsonAnyGetter entries

2 participants