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

Missing value of type JsonNode? is deserialized as NullNode instead of null #490

Closed
novtor opened this issue Aug 26, 2021 · 4 comments · Fixed by #491 or #500
Closed

Missing value of type JsonNode? is deserialized as NullNode instead of null #490

novtor opened this issue Aug 26, 2021 · 4 comments · Fixed by #491 or #500
Assignees
Labels

Comments

@novtor
Copy link

novtor commented Aug 26, 2021

Describe the bug
When in a kotlin data class a parameter is nullable, a payload with a missing value is desirialized and results in NullNode assigned to such a property

To Reproduce
kotlin:
data class TestDataClass(val jsonNodeValue: JsonNode?)
Java:
TestDataClass value = om.readValue("{}", TestDataClass.class); assertThat(value.getJsonNodeValue()).isNull();

Expected behavior
a missing optional value should be desirialized as null and not NullNode

Versions
Kotlin: 1.4
Jackson-module-kotlin: 2.11.4
Jackson-databind: 2.11.4

Additional context
PR: #491

@novtor
Copy link
Author

novtor commented Aug 27, 2021

some debates started here: FasterXML/jackson-databind#3214

@dinomite dinomite self-assigned this Aug 27, 2021
@novtor
Copy link
Author

novtor commented Aug 27, 2021

I added some more test cases that fail even with my changes

@davidopluslau
Copy link

Hi! This is a great change and definitely the better default behavior. However, moving from 2.11 -> 2.13 was a breaking change for us, as we expected a Kotlin non-null value (previously a NullNode) and so threw at runtime. We've already fixed this by allowing null values, but it was a surprising change that required a non-trivial change. Is there any way to configure the object mapper to toggle between these two behaviors?

@cowtowncoder
Copy link
Member

No, unfortunately there is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment