Skip to content

Commit db59b56

Browse files
committed
Merge branch 'master' into tatu/3.0/887-use-module-info
2 parents c788e21 + c95174c commit db59b56

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.19.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #914: Add test case to serialize Nothing? (for #314)
2122
* #910: Add default KeyDeserializer for value class
2223
* #885: Performance improvement of strictNullChecks
2324
* #884: Changed the base class of MissingKotlinParameterException to InvalidNullException

release-notes/VERSION-2.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Co-maintainers:
1818

1919
2.19.0 (not yet released)
2020

21-
#910: A default `KeySerializer` for `value class` has been added.
22-
This eliminates the need to have a custom `KeySerializer` for each `value class` when using it as a key in a `Map`, if only simple boxing is needed.
21+
#910: A default `KeyDeserializer` for `value class` has been added.
22+
This eliminates the need to have a custom `KeyDeserializer` for each `value class` when using it as a key in a `Map`, if only simple boxing is needed.
2323
#889: Kotlin has been upgraded to 1.9.25.
2424
#885: A new `StrictNullChecks` option(KotlinFeature.NewStrictNullChecks) has been added which greatly improves throughput.
2525
Benchmarks show a consistent throughput drop of less than 2% when enabled (prior to the improvement, the worst throughput drop was more than 30%).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package tools.jackson.module.kotlin.test.github
2+
3+
import tools.jackson.databind.MapperFeature
4+
import tools.jackson.module.kotlin.jsonMapper
5+
import tools.jackson.module.kotlin.kotlinModule
6+
import kotlin.test.Test
7+
import kotlin.test.assertEquals
8+
9+
class GitHub314 {
10+
// Since Nothing? is compiled as a Void, it can be serialized by specifying ALLOW_VOID_VALUED_PROPERTIES
11+
data object NothingData {
12+
val data: Nothing? = null
13+
}
14+
15+
@Test
16+
fun test() {
17+
val expected = """{"data":null}"""
18+
19+
val withoutKotlinModule = jsonMapper { enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES) }
20+
assertEquals(expected, withoutKotlinModule.writeValueAsString(NothingData))
21+
22+
val withKotlinModule = jsonMapper {
23+
enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES)
24+
addModule(kotlinModule())
25+
}
26+
27+
assertEquals(expected, withKotlinModule.writeValueAsString(NothingData))
28+
}
29+
}

src/test/kotlin/tools/jackson/module/kotlin/test/github/GitHub844.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
44
import tools.jackson.module.kotlin.readValue
55
import tools.jackson.module.kotlin.jsonMapper
66
import org.junit.jupiter.api.Test
7+
import tools.jackson.module.kotlin.jacksonObjectMapper
78
import kotlin.test.assertEquals
89

910
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type")
@@ -21,7 +22,7 @@ class GitHub844 {
2122
}
2223
"""
2324

24-
val jacksonObjectMapper = jsonMapper()
25+
val jacksonObjectMapper = jacksonObjectMapper()
2526
val message = jacksonObjectMapper.readValue<BaseClass>(json)
2627

2728
assertEquals(ChildClass("Test"), message)

0 commit comments

Comments
 (0)