FasterXML / FasterXML/jackson-module-kotlin
2.15.0 does not seem to honor PropertyAccessor.IS_GETTER visibility anymore
- Dominant language
- Kotlin
- Stars
- 1.2k
- Forks
- 187
- Avg merge
- 9h 48m
- Merged PRs (30d)
- 16
Description
Here is a small main reproducing the behaviour change:
```kt
import com.fasterxml.jackson.annotation.JsonAutoDetect
import com.fasterxml.jackson.annotation.PropertyAccessor
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
fun main() {
val mapper = ObjectMapper().apply {
registerModule(KotlinModule.Builder().build())
setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE)
}
class Foo(val bar: Int) {
val isZero get() = bar == 0
}
println(mapper.writeValueAsString(Foo(1)))
// with Jackson 2.14.2, prints: {"bar":1}
// with Jackson 2.15.0, prints: {"bar":1,"isZero":false}
}
```
We serialize these classes with `setVisibility(PropertyAccessor.IS_GETTER, Visibility.NONE)` to ignore the isXXX methods, and we cannot use `@JsonIgnore` ("This annotation is not applicable to target 'member property without backing field or delegate'").
Starting with Jackson 2.15.0, the `isZero` property is serialized, then the deserialization fails. Please also note that the issue only appears when we register KotlinModule.
The way we use the visibility feature looks fine to me, the property was correctly ignored at serialization with version 2.14.2, so I would say the 2.15 change does look like a regression.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.