-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.15.0 does not seem to honor PropertyAccessor.IS_GETTER visibility anymore #669
Comments
@cowtowncoder Is this expected behavior? I will see if this can be accomplished by customizing the |
Hmmmh. I had to read that one couple of times through... I think the problem is that "implicit name" returned by AI does not denote whether it might be is-getter or regular getter. And then just proceeds to check for regular-getter rules. It is bit of a short-coming, or oversight. I think that given how things are, this probably needs to be considered working as designed. It is not optimal but I am not sure it can be easily changed. |
@cowtowncoder
It is true that
Agreed. By the way, is there a way to customize I think that creating an |
Looking into where FWTW I think I was thinking of this extension point to help with Kotlin is-getters, but did not follow up on the idea. |
I have done some research and it seems to me that, assuming the current implementation, it would be quite difficult to solve this problem. Customize
|
In the meantime, I will also share my own workaround idea. class IgnoreIsGetterAnnotationIntrospector : NopAnnotationIntrospector() {
override fun hasIgnoreMarker(m: AnnotatedMember): Boolean = (m as? AnnotatedMethod)
?.let { _ -> m.name.startsWith("is") }
?: false
}
fun createMapper(): ObjectMapper {
val module = object : SimpleModule() {
override fun setupModule(context: SetupContext) {
super.setupModule(context)
context.appendAnnotationIntrospector(IgnoreIsGetterAnnotationIntrospector())
}
}
return jacksonObjectMapper().registerModule(module)
} |
Thank you for the analysis @k163377, makes sense. Unfortunately there is no obvious easy solution. Workaround might be useful for users in the meantime. |
Here is a small main reproducing the behaviour change:
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.
The text was updated successfully, but these errors were encountered: