-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fixing records deserialization issues with read-access when json renamed to same property name #5072
Conversation
…ame property name
CLA signed earlier today for this repoisotry |
Signed-off-by: Fawzi Essam <[email protected]>
src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
Outdated
Show resolved
Hide resolved
src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithJsonIgnoreTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fawzi Essam <[email protected]>
Signed-off-by: Fawzi Essam <[email protected]>
src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
Outdated
Show resolved
Hide resolved
src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithJsonIgnoreTest.java
Outdated
Show resolved
Hide resolved
src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithJsonIgnoreTest.java
Show resolved
Hide resolved
2 quick questions:
On (2), actually, I think I could try cherry-picking after merging this against 2.19 so that's probably fine. |
Signed-off-by: Fawzi Essam <[email protected]>
|
@iifawzi Ok if it's simple enough, separate PR against 2.18 would be ideal. If not, I can figure out cherry-picking. This is excellent progress -- thank you very much for working on this! |
Thank you @cowtowncoder! |
Superceded by #5073, closing. |
Hello, this is an attempt to resolve deserialization issues when
@JsonProperty.value
has the same name as the property.After debugging, I realized that this's the root cause of #5049. Given for records no constructors' parameters, this condition always passes for both attributes because for read-access only, ctorParam is always null due to
removeNonVisible
logic.Changing this to ensure we don't get into the replacement if it is null seemed enough to fix the duplicate issue and to also fix the ignorance of the access for records #4628
jackson-databind/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
Line 1815 in 25e1135
However, as this seems to be fixing all issues related to records, it's still not fixing the issue with
JsonIgnore
mentioned #4628. The root cause is this:jackson-databind/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
Lines 1436 to 1449 in 25e1135
given we're renaming to same property name, it's then removed from the ignorable list, I'm still unsure of how this should be fixed, so will try to tackle it in a separate PR, in this PR I marked the test as expected to fail so we're aware of it.