Skip to content

Fix #892: ignore whitespace-only unnamed XML text as unknown property - #898

Open
arimu1 wants to merge 1 commit into
FasterXML:3.xfrom
arimu1:fix/892-whitespace-unknown-property
Open

Fix #892: ignore whitespace-only unnamed XML text as unknown property#898
arimu1 wants to merge 1 commit into
FasterXML:3.xfrom
arimu1:fix/892-whitespace-unknown-property

Conversation

@arimu1

@arimu1 arimu1 commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #892

Root cause

Pretty-printed XML with attribute-only beans/records exposes whitespace-only element body as the unnamed XML text property ("" by default). With FAIL_ON_UNKNOWN_PROPERTIES that synthetic property is treated as unknown, even though it is only formatting whitespace between the start and end tags.

This is the same unnamed-text channel used for @JacksonXmlText ([dataformat-xml#565]); it should fail only when the text is actual unknown content.

Change

  • Override XmlDeserializationContext.handleUnknownProperty to skip the unnamed text property when its value is whitespace-only.
  • Mapped @JacksonXmlText is unchanged (the property is known).
  • Non-whitespace unnamed text still fails when the property is unknown.

Test plan

  • WhitespaceOnlyUnknownProp892Test — issue XML on records + POJO; non-whitespace body still UnrecognizedPropertyException
  • Neighbors: XmlTextWhitespace565Test, EmptyBeanDeser318Test, XmlEmptyRecordDeser508Test, XmlRecordDeser735Test, XmlClassDeser735Test, TextValueTest, XmlTextTest
  • Full mvn test on JDK 21

AI-assisted (Composer 2.5); human-reviewed.

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.

XmlMapper with FAIL_ON_UNKNOWN_PROPERTIES fails on whitespace-only element

1 participant