File tree 2 files changed +15
-10
lines changed
main/kotlin/io/github/projectmapk/jackson/module/kogera
test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,19 @@ internal inline fun <reified T> Any?.checkTypeMismatch(): T {
82
82
public inline fun <reified T > ObjectMapper.readValue (jp : JsonParser ): T = readValue(jp, jacksonTypeRef<T >())
83
83
.checkTypeMismatch()
84
84
85
- // TODO: After importing 2.19, import the changes in kotlin-module and uncomment the tests.
86
- public inline fun <reified T > ObjectMapper.readValues (
87
- jp : JsonParser
88
- ): MappingIterator <T > = readValues(jp, jacksonTypeRef<T >())
85
+ /* *
86
+ * Shorthand for [ObjectMapper.readValues].
87
+ * @throws RuntimeJsonMappingException Especially if [T] is non-null and the value read is null.
88
+ * Other cases where the read value is of a different type than [T]
89
+ * due to an incorrect customization to [ObjectMapper].
90
+ */
91
+ public inline fun <reified T > ObjectMapper.readValues (jp : JsonParser ): MappingIterator <T > {
92
+ val values = readValues(jp, jacksonTypeRef<T >())
93
+
94
+ return object : MappingIterator <T >(values) {
95
+ override fun nextValue (): T = super .nextValue().checkTypeMismatch()
96
+ }
97
+ }
89
98
90
99
/* *
91
100
* Shorthand for [ObjectMapper.readValue].
Original file line number Diff line number Diff line change @@ -38,9 +38,7 @@ class ReadValuesTest {
38
38
val itr = mapper.readValues<String >(src)
39
39
40
40
assertEquals(" foo" , itr.next())
41
- // TODO: It is expected to be checked after importing 2.19.
42
- // assertThrows<RuntimeJsonMappingException> {
43
- assertDoesNotThrow {
41
+ assertThrows<RuntimeJsonMappingException > {
44
42
itr.next()
45
43
}
46
44
}
@@ -51,9 +49,7 @@ class ReadValuesTest {
51
49
val itr = mapper.readValues<String >(src)
52
50
53
51
assertEquals(" foo" , itr.nextValue())
54
- // TODO: It is expected to be checked after importing 2.19.
55
- // assertThrows<RuntimeJsonMappingException> {
56
- assertDoesNotThrow {
52
+ assertThrows<RuntimeJsonMappingException > {
57
53
itr.nextValue()
58
54
}
59
55
}
You can’t perform that action at this time.
0 commit comments