Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Jul 6, 2024
2 parents b556242 + e48cfb4 commit 1da869e
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
2 changes: 1 addition & 1 deletion src/main/kotlin/tools/jackson/module/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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 = forType(jacksonTypeRef<T>()).readValue(jp)
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 tools.jackson.databind.json.JsonMapper
import tools.jackson.module.kotlin.KotlinFeature
import tools.jackson.module.kotlin.KotlinModule
import tools.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 1da869e

Please sign in to comment.