-
-
Notifications
You must be signed in to change notification settings - Fork 177
Deserialization of generic class with nullable values failes #917
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
Comments
I think there is a flaw in the extension methods in regards to nullable types.
it is possible to write code like:
and the value of I think a better implementation might be:
which would make the above usage fail to compile and force the usage to look like thiss:
This is a more accurate representation of the fact that the I would be happy to open a PR for this, if @cowtowncoder and @k163377 agree that this is better. |
I have done some more investigating, and found that while the above change would work for the nullability of the outer types, it would not work for generic type parameters. for example, it would still allow for something like this to be written:
which would still rely on runtime null enforcing |
@Janik7777 The direct cause of this problem is that the First, it seems that Next, I thought about setting the Finally, I thought about forcing an override of the I believe the most practical thing to do would be to modify |
@wakingrufus
That is a different issue, duplicate of #399.
Such interface changes are unacceptable because they are destructive changes that cause compile errors. |
Regarding the above comment, functionality has been added to 2.19 so that workarounds for manual specification will now work. |
Search before asking
Describe the bug
Error occurs during deserialization of my generic class:
This is my data class
I want use it for non null and nullable data types for T. One example usage would be:
We want our YAML file only to include non-null fields, so we use the option
setSerializationInclusion(JsonInclude.Include.NON_NULL)
for the mapper.But now the deserialization fails.
To Reproduce
Expected behavior
deserializedValue == Example<String?>(null, 10)
Versions
Kotlin:
Jackson-module-kotlin: 2.18.2
Jackson-databind: 2.18.2
Additional context
No response
The text was updated successfully, but these errors were encountered: