Skip to content

2.15.0 does not seem to honor PropertyAccessor.IS_GETTER visibility anymore #3904

@fleiber

Description

@fleiber

Here is a small main reproducing the behaviour change:

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 please note that 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.
The way we use the visibility feature looks fine to me, this property was correctly ignored at serialization with version 2.14.2, so I would say the 2.15 change does look like a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    to-evaluateIssue that has been received but not yet evaluated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions