FasterXML / FasterXML/jackson-module-kotlin

2.15.0 does not seem to honor PropertyAccessor.IS_GETTER visibility anymore

Offen
#669 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Kotlin
Sterne
1.2k
Forks
187
Ø Merge
9 Std. 48 Min.
Gemergte PRs (30 T.)
16

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.