Skip to content

Commit 4dbc514

Browse files
committed
Fix #270 /cc @apatrida (sanity check would be appreciated)
1 parent e93f137 commit 4dbc514

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

release-notes/VERSION-2.x

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Project: jackson-module-kotlin
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
2.10.2 (not yet released)
8+
9+
#270: 2.10.1 seems to output JSON field where name of function matches
10+
name of private field
11+
(reported by daviddenton@github)
12+
713
2.10.1 (10-Nov-2019)
814

915
#80: Boolean property name starting with 'is' not serialized/deserialized properly

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
3333
// 25-Oct-2019: [module-kotlin#80] Match "isGetter" with field with same name
3434
// since Kotlin generates accessor different from Java
3535
if (member.declaringClass.isKotlinClass()) {
36-
if (cache.isKotlinGeneratedMethod(member) { it.declaringClass.declaredFields.any { f -> f.name == member.name } }) {
36+
if (cache.isKotlinGeneratedMethod(member) { it.declaringClass.declaredFields.any {
37+
f -> f.name.startsWith("is") && f.name == member.name } }) {
3738
return member.name
3839
}
3940
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github114.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TestGithub114 {
5858
val v = Nada.Companion::foo
5959
assertEquals("OK 42", v.callBy(mapOf()))
6060
val v2 = FooWithStaticCreator.Companion::createFromJson.javaMethod!!.kotlinFunction!!
61-
println(v2.callBy(mapOf(v2.parameters.first() to FooWithStaticCreator, v2.parameters.drop(1).first() to "asdf")))
61+
// println(v2.callBy(mapOf(v2.parameters.first() to FooWithStaticCreator, v2.parameters.drop(1).first() to "asdf")))
6262
}
6363

6464
private class Nada {
@@ -67,6 +67,4 @@ class TestGithub114 {
6767
fun foo(x: Int = 42) = "OK $x"
6868
}
6969
}
70-
71-
72-
}
70+
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github149.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ class TestGithub149 {
4747
val f1 = Foo("f1", listOf(fAtt))
4848
fAtt.parent = f1
4949

50-
println(f1)
51-
println("=============")
50+
// println(f1)
51+
// println("=============")
5252

5353
val f1AsJson = mapper.writeValueAsString(f1)
54-
println(f1AsJson)
55-
println("=============")
54+
// println(f1AsJson)
55+
// println("=============")
5656
val mFromJson = mapper.readValue(f1AsJson, Foo::class.java)
57-
println(mFromJson)
57+
// println(mFromJson)
5858
}
5959

6060
data class Car(
@@ -81,6 +81,6 @@ class TestGithub149 {
8181
c.colors.add(color)
8282
val s = mapper.writeValueAsString(c)
8383
val value = mapper.readValue(s, Car::class.java)
84-
print(value)
84+
// print(value)
8585
}
8686
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/failing/Github270.kt renamed to src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github270.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.module.kotlin.test.failing
1+
package com.fasterxml.jackson.module.kotlin.test.github
22

33
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
44
import org.junit.Test

0 commit comments

Comments
 (0)