Skip to content

Commit

Permalink
Merge pull request #817 from k163377/fix/757
Browse files Browse the repository at this point in the history
Fixed nullability of `convertValue` function argument
  • Loading branch information
k163377 authored Jul 6, 2024
2 parents b0eab85 + 54a3fc5 commit e48cfb4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Authors:
Contributors:

# 2.18.0 (not yet released)

WrongWrong (@k163377)
* #817: Fixed nullability of convertValue function argument
* #782: Organize deprecated contents
* #542: Remove meaningless checks and properties in KNAI

Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Co-maintainers:

2.18.0 (not yet released)

#817: The convertValue extension function now accepts null
#803: Kotlin has been upgraded to 1.8.10.
The reason 1.8.22 is not used is to avoid KT-65156.
#782: Content marked as deprecated has been reorganized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline fun <reified T> ObjectMapper.readValue(src: InputStream): T = readValue(s
inline fun <reified T> ObjectMapper.readValue(src: ByteArray): T = readValue(src, jacksonTypeRef<T>())

inline fun <reified T> ObjectMapper.treeToValue(n: TreeNode): T = readValue(this.treeAsTokens(n), jacksonTypeRef<T>())
inline fun <reified T> ObjectMapper.convertValue(from: Any): T = convertValue(from, jacksonTypeRef<T>())
inline fun <reified T> ObjectMapper.convertValue(from: Any?): T = convertValue(from, jacksonTypeRef<T>())

inline fun <reified T> ObjectReader.readValueTyped(jp: JsonParser): T = readValue(jp, jacksonTypeRef<T>())
inline fun <reified T> ObjectReader.readValuesTyped(jp: JsonParser): Iterator<T> = readValues(jp, jacksonTypeRef<T>())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.fasterxml.jackson.module.kotlin.test.github

import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.convertValue
import kotlin.test.Test
import kotlin.test.assertNull

class GitHub757 {
@Test
fun test() {
val kotlinModule = KotlinModule.Builder()
.enable(KotlinFeature.StrictNullChecks)
.build()
val mapper = JsonMapper.builder()
.addModule(kotlinModule)
.build()
val convertValue = mapper.convertValue<String?>(null)
assertNull(convertValue)
}
}

0 comments on commit e48cfb4

Please sign in to comment.