Skip to content

Enforce nullability at deserialization time (issue #373) #376

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

Closed
wants to merge 1 commit into from

Conversation

rafalbednarczuk
Copy link

No description provided.

@rafalbednarczuk
Copy link
Author

I don't know which Exception should be used here


inline fun <reified T> T.throwIfNullableTypeIsNull(): T {
if (null !is T && this == null) {
throw Exception()
Copy link
Member

@cowtowncoder cowtowncoder Sep 25, 2020

Choose a reason for hiding this comment

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

This is bit tricky because failure happens outside of call that has DeserializationContext -- usually you'd call context.reportInputMismatch(...) (or similar). That throws MismatchedInputException, for what that is worth.
That is used by databind. Might be worth checking how Kotlin module indicates errors however.
@dinomite and @viartemev can give more guidance (and would be ones reviewing this, indicating whether approach makes sense to them)

@dinomite dinomite changed the title fix #373 Enforce nullability at deserialization time (issue #373) Dec 23, 2020
@dinomite dinomite added the 2.12 label Dec 23, 2020
@dinomite dinomite self-assigned this Dec 23, 2020
@dinomite dinomite changed the base branch from master to 2.12 January 1, 2021 19:01
@dinomite dinomite changed the base branch from 2.12 to master January 1, 2021 19:01
@dinomite
Copy link
Member

dinomite commented Jan 1, 2021

Closing in favor of 405 which is based upon 2.12.

@dinomite dinomite closed this Jan 1, 2021
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.

3 participants