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

Support DEDUCTION of empty subtypes #3140

Merged
merged 1 commit into from
May 3, 2021

Conversation

drekbour
Copy link
Contributor

@drekbour drekbour commented May 3, 2021

Support deduction of empty subtypes (classes with no distinguishing properties at all) against empty json ({}).

Incoming null, <absent> and use of ignoreUnknownProperties will not NOT match an empty subtype. In keeping with the affirmative matching used by the rest of the deduction mode, there can be only a single empty subtype and only an explicitly empty object ({}) will match it.

Inspired by #3137 - thanks to @xJoeWoo for the report

This is raised against 2.12 but can be rebased onto 2.13 on request

@cowtowncoder
Copy link
Member

Ok, so my instinct is this should be safe enough for 2.12 -- the only possible concern is the change to check current token is not END_OBJECT... but I think I'll take my chances with that. So this will be available in 2.12.4 if that gets released before 2.13.

@cowtowncoder cowtowncoder merged commit 4231bb1 into FasterXML:2.12 May 3, 2021
@drekbour
Copy link
Contributor Author

drekbour commented May 3, 2021

The END_OBJECT conditional is because all preceding property-based type deserialisers had to parse at least one property to work. Only with this PR do we allow {} through the normal path, where it arrives already placed on END_OBJECT token. At least that was my reading of this method when making the change.

@drekbour drekbour deleted the deduction_of_empty_subtype branch May 3, 2021 22:09
@cowtowncoder
Copy link
Member

Makes sense -- did not mean to imply there is no reason (and similar checks have been sometimes needed for various reasons in other places). Just that it is possible that some edge case somewhere might be relying on specific set of things (f.ex, XML handling), and might break either legitimately or (more likely) due to incorrect assumptions.

Having said that check looks sensible to me so I'm ok in assuming it all works unless proven otherwise :)

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