FasterXML / jackson-module-kotlin

Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Apache License 2.0
1.12k stars 175 forks source link

Regression since 2.12.1 if class has attributes with names xxx and `xxx-yyy` - Error :Conflicting getter definitions for property #678

Closed drapej closed 1 year ago

drapej commented 1 year ago

Describe the bug Hi, since the version 2.12.1 (don't have the problem in version 2.12.0), I have a problem to serialize a data class with this structure (see below). I have see error : Conflicting getter definitions for property "content": Export#getContent() vs Export#getContent-Type() com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "content": Export#getContent() vs Export#getContent-Type() at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:288) at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1308)

So I made some test and I if rename the attribut Content-Type without the "-" ("ContentType") or Content2-Type, I don't have any problem. Why I have this problem ? The regression is that normal ? How can I fix that ? (without rename my attributes) Thanks

To Reproduce

data class Export(val filename: String, val content: String, val `Content-Type`: Charset = Charsets.UTF_8)

fun main() {
    val export = Export("test","contentvaleur")
    jacksonObjectMapper().writeValueAsString(export)
}

Expected behavior {"filename":"...", "content":"...", "Content-Type":"..."}

Versions Kotlin:1.6.21 Jackson-module-kotlin: 2.12.1 Jackson-databind: 2.12.1

k163377 commented 1 year ago

This issue will be fixed by #630 and therefore closed as a duplicate.