Skip to content

recompute XML metadata for filtered props in XmlBeanSerializerBase - #907

Open
Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:filtered-props-xml-metadata
Open

recompute XML metadata for filtered props in XmlBeanSerializerBase#907
Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:filtered-props-xml-metadata

Conversation

@Sahana2524

Copy link
Copy Markdown
Contributor

Wrong-property XML metadata after @JsonIgnoreProperties

XmlBeanSerializerBase keeps four index-parallel structures (_attributeCount, _textPropertyIndex, _xmlNames, _cdata) that the base constructor derives from _props. The (src, toIgnore, toInclude) and (src, properties, filteredProperties) constructors copied them straight from src, but super(...) there rebuilds _props with a shorter or re-ordered set, so every slot after a dropped or moved property lands on the wrong one. A member-level @JsonIgnoreProperties/@JsonIncludeProperties (which routes through withByNameInclusion) or a modifier that hands back withProperties(...) is enough to hit it, and nothing throws: a plain element gets emitted as an attribute, a @JacksonXmlText value swaps places with the next element, or CDATA attaches to a neighbor, so the output no longer reads back to the same object.

Moved the derivation into a shared helper and recomputed it against the rebuilt array in those two constructors; the copy-from-src path stays for the constructors that keep the same property set. Added regression tests for the attribute, text, and CDATA cases (each fails before the change). Full suite green under ./mvnw -B -ff -ntp verify.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 74.47% 📈 +0.280%
Branches branches 69.02% 📈 +0.050%

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant