Skip to content

Commit f1a3c9b

Browse files
author
ddomanine
committed
if value is missing, rely on deserilizer.getAbscentValue instead of deserilizer.getNullValue. Fixing tests
1 parent d88a3d6 commit f1a3c9b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinValueInstantiator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ internal class KotlinValueInstantiator(
102102
tempParamVal
103103
} else {
104104
if(paramDef.type.isMarkedNullable) {
105-
// do not try to create any object if it is nullable
105+
// do not try to create any object if it is nullable and the value is missing
106106
null
107107
} else {
108-
// trying to get suitable "missing" value provided by deserializer
109-
jsonProp.valueDeserializer?.getNullValue(ctxt)
108+
// to get suitable "missing" value provided by deserializer
109+
jsonProp.valueDeserializer?.getAbsentValue(ctxt)
110110
}
111111
}
112112

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github490.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fasterxml.jackson.module.kotlin.test.github
22

33
import com.fasterxml.jackson.databind.JsonNode
4+
import com.fasterxml.jackson.databind.node.NullNode
45
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
56
import com.fasterxml.jackson.module.kotlin.readValue
67
import org.hamcrest.CoreMatchers
@@ -45,9 +46,9 @@ class TestGithub490 {
4546
@Test
4647
fun testKotlinDeserialization_jsonNodeValueProvidedNull() {
4748
assertThat(
48-
"Nullable JsonNode value provided as null should be deserialized as null and not as NullNode",
49+
"Nullable JsonNode value provided as null should be deserialized as NullNode",
4950
value.jsonNodeValueProvidedNull,
50-
CoreMatchers.nullValue()
51+
CoreMatchers.equalTo(NullNode.instance)
5152
)
5253
}
5354

@@ -63,9 +64,9 @@ class TestGithub490 {
6364
@Test
6465
fun testKotlinDeserialization_jsonNodeValueWithNullAsDefaultProvidedNull() {
6566
assertThat(
66-
"Nullable by default JsonNode with provided null value in payload should be deserialized as null and not as NullNode",
67+
"Nullable by default JsonNode with provided null value in payload should be deserialized as NullNode",
6768
value.jsonNodeValueWithNullAsDefaultProvidedNull,
68-
CoreMatchers.nullValue()
69+
CoreMatchers.equalTo(NullNode.instance)
6970
)
7071
}
7172
}

0 commit comments

Comments
 (0)