Skip to content

Commit

Permalink
Fix #270 /cc @apatrida (sanity check would be appreciated)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 28, 2019
1 parent e93f137 commit 4dbc514
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
6 changes: 6 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Project: jackson-module-kotlin
=== Releases ===
------------------------------------------------------------------------

2.10.2 (not yet released)

#270: 2.10.1 seems to output JSON field where name of function matches
name of private field
(reported by daviddenton@github)

2.10.1 (10-Nov-2019)

#80: Boolean property name starting with 'is' not serialized/deserialized properly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
// 25-Oct-2019: [module-kotlin#80] Match "isGetter" with field with same name
// since Kotlin generates accessor different from Java
if (member.declaringClass.isKotlinClass()) {
if (cache.isKotlinGeneratedMethod(member) { it.declaringClass.declaredFields.any { f -> f.name == member.name } }) {
if (cache.isKotlinGeneratedMethod(member) { it.declaringClass.declaredFields.any {
f -> f.name.startsWith("is") && f.name == member.name } }) {
return member.name
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TestGithub114 {
val v = Nada.Companion::foo
assertEquals("OK 42", v.callBy(mapOf()))
val v2 = FooWithStaticCreator.Companion::createFromJson.javaMethod!!.kotlinFunction!!
println(v2.callBy(mapOf(v2.parameters.first() to FooWithStaticCreator, v2.parameters.drop(1).first() to "asdf")))
// println(v2.callBy(mapOf(v2.parameters.first() to FooWithStaticCreator, v2.parameters.drop(1).first() to "asdf")))
}

private class Nada {
Expand All @@ -67,6 +67,4 @@ class TestGithub114 {
fun foo(x: Int = 42) = "OK $x"
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class TestGithub149 {
val f1 = Foo("f1", listOf(fAtt))
fAtt.parent = f1

println(f1)
println("=============")
// println(f1)
// println("=============")

val f1AsJson = mapper.writeValueAsString(f1)
println(f1AsJson)
println("=============")
// println(f1AsJson)
// println("=============")
val mFromJson = mapper.readValue(f1AsJson, Foo::class.java)
println(mFromJson)
// println(mFromJson)
}

data class Car(
Expand All @@ -81,6 +81,6 @@ class TestGithub149 {
c.colors.add(color)
val s = mapper.writeValueAsString(c)
val value = mapper.readValue(s, Car::class.java)
print(value)
// print(value)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin.test.failing
package com.fasterxml.jackson.module.kotlin.test.github

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.junit.Test
Expand Down

0 comments on commit 4dbc514

Please sign in to comment.