Skip to content

Commit 19c5c02

Browse files
committed
added consideration for cases where the value wrapped by value class is null
1 parent db939c7 commit 19c5c02

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
9494
else -> null
9595
}
9696

97+
// Perform proper serialization even if the value wrapped by the value class is null.
98+
override fun findNullSerializer(am: Annotated) = findSerializer(am)
99+
97100
/**
98101
* Subclasses can be detected automatically for sealed classes, since all possible subclasses are known
99102
* at compile-time to Kotlin. This makes [com.fasterxml.jackson.annotation.JsonSubTypes] redundant.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal class ValueClassBoxSerializer(
8282
) : StdSerializer<Any>(outerClazz.java) {
8383
private val boxMethod = _handledType.getMethod("box-impl", innerClazz)
8484

85-
override fun serialize(value: Any, gen: JsonGenerator, provider: SerializerProvider) {
85+
override fun serialize(value: Any?, gen: JsonGenerator, provider: SerializerProvider) {
8686
// Values retrieved from getter are considered validated and constructor-impl is not executed.
8787
val boxed = boxMethod.invoke(null, value)
8888

0 commit comments

Comments
 (0)