Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@JacksonXmlProperty appears to behave differently than @JsonProperty when used on java records #665

Open
alexkolson opened this issue Aug 4, 2024 · 1 comment

Comments

@alexkolson
Copy link

Hello there,

First off, I have created a test repository on github where you can see this for yourself, either in the github action runs or by checking it out locally and running mvn test: jackson-annotation-processing-experiment.

It seems that as soon as one specifies a @JacksonXmlProperty annotation on a java record property, then one has to supply the localName argument to the annotation, otherwise, when deserializing an xml document into the record representation, you get a "Duplicate creator property" error. This is different behavior than @JsonProperty, which one can specify on a record without supplying it any arguments and it works just fine.

I am aware that one can simply not add any annotation, and deserialization works just fine. I noticed this issue though when trying to use isAttribute=true on a @JacksonXmlProperty on a java record, as an xml document I need to deserialize uses attributes. I am also aware that once you specify localName, deserialization also works. What puzzles me is that the simple presence of a @JacksonXmlProperty annotation on a java record seems to require the specification of localName, whereas this does not appear to be the case for @JsonProperty.

Any help or tips or ideas you have would be greatly appreciated!

And of course thanks for making such an awesome tool for us, and I realize you owe me absolutely nothing but if you do happen to get a moment to look at this, it would be super cool!

@cowtowncoder
Copy link
Member

Quick note -- and apologies for a slow follow-up -- since Property introspection handling was rewritten in 2.18.0, it might make sense to verify the issue still occurs with 2.18.0-SNAPSHOT versions, as there's a slight chance things might have improved.
If nothing else, that would rule out possibility of a recent indirect fix.

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

No branches or pull requests

2 participants