-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support @JsonIgnoreProperties(allowGetters,allowSetters)
, align with Jackson behaviour
#640
Conversation
…h Jackson behaviour
@@ -687,6 +686,16 @@ private void visitSubtype(ClassElement supertype, ClassElement subtype, VisitorC | |||
return; | |||
} | |||
|
|||
if (!subtype.hasAnnotation(SerdeConfig.SerIgnored.class)) { | |||
// Replicate the Jackson behaviour of using the ignore annotation from supertype but allow to override it | |||
AnnotationValue<SerdeConfig.SerIgnored> serIgnored = supertype.getAnnotation(SerdeConfig.SerIgnored.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it's on the supersupertype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annotation is not inherited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a hierarchy of A extends B and B extends C, and C has @SerIgnored, I think this will mean that A will only get SerIgnored if B is visited before A?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, @SerIgnored
is not inherited, so adding it to B
shouldn't add it to A
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but youre copying it here? i dont understand what youre saying. this code copies the annotation from the supertype, but not if it's further up, even though i assume in jackson it would still be considered for such a hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subtypes in this code are the subtypes of the base class defined by JsonSubTypes. The logic is called one. It’s not called on every type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhhh i see. does that match jackson though? my guess is that with jackson, the property is considered part of the parent class because the parent class defines a getter of that name, so JsonIgnoreProperties is considered even though it's not technically @Inherited
. I doubt this behavior is specific to JsonSubTypes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ignore is not inherited. With subtypes it acts the same, if you put ignore again and want to ignore something from the supertype you need to repeat it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ive pushed a pendingfeature with the setup that i mean. the test passes with jackson-databind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, looks like Jackson respects the last definition. I can take a look in the next PR
serde-support/src/main/java/io/micronaut/serde/support/deserializers/DemuxingObjectDecoder.java
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. 0 Bugs 91.6% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Fixes #581
Fixes #550