Fix #4690, duplicated property to single-property Record #5444
+88
−90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before anything else, thank you for creating such an excellent library.
Whenever I work on the source, I learn a lot from the precision of the code.
issue: #4690
Previously, for record types using a property-based creator, creator.build could be invoked prematurely as soon as all constructor parameters were bound in the parser loop.
As a result, if a duplicate of a creator property appeared later in the JSON, the later value could not be applied, it was either ignored or caused an error ("No fallback setter/field defined for creator property"), since records have no mutable setters.
This PR adjusts the logic so that record types defer creator.build(...) until the end of the object, ensuring that duplicate properties correctly follow the "last value wins" behavior.
In additional, I added a POJO class case(testDuplicatePropertyClassDeserialization) to DuplicatePropertyDeserializationRecord4690Test.
Thank you for taking the time to review this, especially when you're busy.
Have a good day :)