Skip to content

Conversation

pjfanning
Copy link
Member

@pjfanning pjfanning commented Sep 14, 2025

  • adds test like the failing one that was added for XmlMapper maps null value of xml element with atribute #734 - this one works with a Java bean style class but only works if an empty constructor is added
  • useful for regression testing
  • the failing test still fails with latest code but now fails with this when run with Java 17
[ERROR]   XmlRecordDeser734Test.testDeser:25 » InvalidDefinition Invalid definition for property '' (of type `com.fasterxml.jackson.dataformat.xml.records.failing.XmlRecordDeser734Test$Amount`): Could not find creator property with name '' (known Creator properties: [value, Ccy])
 at [Source: (StringReader); line: 1, column: 1]

@pjfanning
Copy link
Member Author

@cowtowncoder Someone else has commented on #735 - which is related to this.

I debugged the failing record test for 734 and the immediate issue is that the PropertyDef for the 'value' field has getName=null. The getInternalName knows the right name ('value'). The new test in this PR (which has a class for Amount instead of a record) has the same issue but it seems to offer up an alternative way to set the value.

In the code snippet for BeanDeserializerFactory, the failure is thrown at line 644.
https://github.com/FasterXML/jackson-databind/blob/866e33850696ed785b1bbfc2d1dac15d188e3a1d/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java#L624-L647

If the code was modified at line 630 to say that if the prop.getName returned null that we failed over to prop.getInternalName then the immediate issue would not happen because a propertyDef would be found. I haven't tested this change and something else might go wrong afterwards.

@cowtowncoder
Copy link
Member

Since #734 was closed as dup for #735 (for same issue), maybe change 734 references to 735?

@pjfanning
Copy link
Member Author

@cowtowncoder renamed tests to reference issue #735

Any thoughts on changing BeanDeserializerFactory and failing over to the propDef.getInternalName when propDef.getName returns a null or empty value?

@pjfanning
Copy link
Member Author

@cowtowncoder the record test for 734 (renamed to 735) seems to pass if you add the param-names module.

        mapper.registerModule(new com.fasterxml.jackson.module.paramnames.ParameterNamesModule());

@pjfanning pjfanning changed the title Create XmlClassDeser734Test.java Create XmlClassDeser735Test.java Sep 15, 2025
@pjfanning
Copy link
Member Author

@cowtowncoder the record test for 734 (renamed to 735) seems to pass if you add the param-names module.

        mapper.registerModule(new com.fasterxml.jackson.module.paramnames.ParameterNamesModule());

Actually, this doesn't work. I must have made a mistake when I ran it earlier.

@cowtowncoder
Copy link
Member

I am not sure about using "getInternalName"; the name really needs to be marker (like empty String) for @JacksonXmlText behavior, so as a general change I don't think that would work.
If I remember correctly, internal here means "implicit" name; default before explicit (annotation) override, if any.

@cowtowncoder cowtowncoder merged commit e003de0 into FasterXML:2.x Sep 18, 2025
4 checks passed
@pjfanning pjfanning deleted the deser-test branch September 18, 2025 09:24
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.

2 participants