-
-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Labels
Description
Search before asking
- I searched in the issues and found nothing similar.
- I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
- I searched in the issues of databind and other modules used and found nothing similar.
- I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.
Describe the bug
There appears to be a regression from StrictNullChecks to NewStrictNullChecks where null values are now allowed in lists if the null value was a result of a type conversion failure (such as a List where a string was passed that is not parseable as an Int)
To Reproduce
data class PrimitiveList(val list: List<Int>)
@Test // PASSES
fun strictNullChecks() {
val om = ObjectMapper(JsonFactory())
om.registerModule(KotlinModule.Builder().enable(KotlinFeature.StrictNullChecks).build())
assertThatException().isThrownBy {
om.readValue("""{"list": ["", "1"] }""".toByteArray(), PrimitiveList::class.java)
}
}
@Test // FAILS because no exception is thrown
fun newStrictNullChecksRegression() {
val om = ObjectMapper(JsonFactory())
om.registerModule(KotlinModule.Builder().enable(KotlinFeature.NewStrictNullChecks).build())
assertThatException().isThrownBy {
om.readValue("""{"list": ["", "1"] }""".toByteArray(), PrimitiveList::class.java)
}
}
Expected behavior
An exception is thrown rather a null value inserted that will lead to a runtime NPE at a later point
Versions
Kotlin:
Jackson-module-kotlin: 2.19.0
Jackson-databind: 2.19.0
Additional context
No response