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

Ignore Records' immutable fields in BeanDeserializerFactory instead of ignoring it in POJOPropertiesCollector, to preserve any annotation info the fields may be carrying. #4627

Merged
merged 7 commits into from
Jul 21, 2024

Conversation

yihtserns
Copy link
Contributor

@yihtserns yihtserns commented Jul 21, 2024

Proposal for #4626.

Turns out Record fields (or rather the annotations on them) are needed for both serialization (#3628, #3895, #3906 (comment)) & deserialization (#4626).

So we need to either keep them or change the way/order we harvest annotation info in POJOPropertiesCollector (for someone who knows every little about the codebase, I only dared to propose the former).

…property when its accessor method is annotated with @JsonIgnore.
@yihtserns yihtserns force-pushed the records-desered-jsonignore branch from f2b2141 to ea3135a Compare July 21, 2024 13:31
…property when a Record's component has @JsonIgnore + the corresponding accessor method is overridden without @JsonIgnore.
…f ignoring it in POJOPropertiesCollector, to preserve any annotation info the fields may be carrying.
@yihtserns yihtserns force-pushed the records-desered-jsonignore branch from ea3135a to 2b4cf9f Compare July 21, 2024 13:33
// since there should not be setters.
final boolean inferMutators = !isRecordType()
&& _config.isEnabled(MapperFeature.INFER_PROPERTY_MUTATORS);
final boolean inferMutators = _config.isEnabled(MapperFeature.INFER_PROPERTY_MUTATORS);
Copy link
Contributor Author

@yihtserns yihtserns Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really understand this change, but I reverted it simply because it was part of #3737 even though it has no effect on #4626.

But I just found out that reverting this fixed #4630.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

…operty when a Record's component has @JsonIncludeProperties/@JsonIgnoreProperties + the corresponding accessor method is overridden.
@cowtowncoder
Copy link
Member

@yihtserns Overall I think that makes sense, given it addresses problems you demonstrated.
Just want to change the checking of if an AnnotatedField is part of Record a bit, to do it at caller, not within AnnotatedField itself (since caller has all the information about declaring type).

@yihtserns
Copy link
Contributor Author

yihtserns commented Jul 21, 2024

Although there's no test, I just found out that this change broke #562 implementation for Records...

Could've closed #3439, but now it's blocked again... 😢

@cowtowncoder cowtowncoder merged commit f26f9e3 into FasterXML:2.18 Jul 21, 2024
7 checks passed
@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 21, 2024

@yihtserns Ugh. Could you file a separate new issue (referencing #562 and this PR)?
Too bad we have many tests for POJOs wrt 562, but not any Record one.

Btw, big THANK YOU for finding all these issues as well as obviously fixing.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 21, 2024

@yihtserns Not only that, but looks like jackson-module-kotlin (2.18 and master) tests started failing :-(

https://github.com/FasterXML/jackson-module-kotlin/actions/runs/10031852459

(on plus side, cascading rebuilds expose these failures sooner)

/cc @k163377

@yihtserns
Copy link
Contributor Author

yihtserns commented Jul 21, 2024

@cowtowncoder Seems like this is a bad PR, can you please revert it and I'll see if I can rework it?

Sorry for the trouble.

@cowtowncoder
Copy link
Member

@yihtserns was about to suggest the same. Will do.

One thing that'd be good would be to take unit tests from here, add under .../failing.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 22, 2024

@yihtserns Hmmmh. This is odd... Kotlin failures remain after revert. So it seems some other commit broke it, not this PR. But I don't see previous cascading build failures so I am bit confused as to what might have caused breakage.
Perhaps this could be re-applied, if #562 problem could be resolved.

cc @k163377 Looks like there are 3 test failures for jackson-module-kotlin; unclear what changed to cause that.

@yihtserns
Copy link
Contributor Author

Created PR #4633 to add test cases for Records+JsonAnySetter including all the workarounds shared in #3439.

@yihtserns
Copy link
Contributor Author

yihtserns commented Jul 22, 2024

@cowtowncoder I suspect the Kotlin failure is caused by Kotlin refusing to play nice with FasterXML/jackson-annotations#258 (it generated a dodgy looking .class).

I downgraded jackson-annotations to 2.17.2 locally and the tests are passing again.

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