You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The intention of the example below is that the bean's value is serialised as both ownerUid and accountOwnerUid and that deserialisation uses the ownerUid value. The example can be made to work by removing the ParameterNameModules and relying on the @JsonProperty annotation. It appears to be rather a contrived example (it reflects some real examples, promise); I wanted to report it because I feel that it's fairly clear what the code should do and the behaviour is unexpected.
The error when running the test using Jackson 2.9.9.1 is: com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "ownerUid": com.example.rest.server.RestServerJacksonModuleTest$TestBeanWithAnnotationsAndDeprecation#getOwnerUid(0 params) vs com.example.rest.server.RestServerJacksonModuleTest$TestBeanWithAnnotationsAndDeprecation#getAccountOwnerUid(0 params)
The difference between running the test with the parameter names module is that _renameProperties in POJOPropertiesCollector decides that the property needs to be renamed. The breakpoint in there is not hit without the parameter names module being registered with the ObjectMapper.
The text was updated successfully, but these errors were encountered:
I can see how/why property introspector gets confused: the problem comes from multiple factors...
Implied name (ONLY found if parameter names module registered) for 2nd argument is accountOwnerUid
There is also getAccountOwnerUid(), which is then linked with constructor argument
Due to rename of (1), both of these essentially get renamed as "ownerUid"
Alas, there is also the "real" ownerUid() getter, getOwnerUid()
Now: while I can see what intent is, question is whether it is possible to resolve it reliably without breaking something else.
Now... assuming @Deprecated means that that getter is NOT to be used, changing that to @JsonIgnore should resolve the problem as it will ignore just that accessor but not others, because of existence of @JsonProperty.
Alternatively, I think that adding @JsonProperty next to getAccountOwnerUid() (or, if I misunderstood, next to getOwnerUid()) would also resolve the situation as one accessor would be explicit, other not (just implicit based on name).
So: on short term I would add either @JsonIgnore or @JsonProperty to break the ambiguity (from Jackson POV).
I am open to suggestion on logic for other tie-breakers, but this seems like bit of a tricky case.
The intention of the example below is that the bean's value is serialised as both
ownerUid
andaccountOwnerUid
and that deserialisation uses theownerUid
value. The example can be made to work by removing the ParameterNameModules and relying on the @JsonProperty annotation. It appears to be rather a contrived example (it reflects some real examples, promise); I wanted to report it because I feel that it's fairly clear what the code should do and the behaviour is unexpected.The error when running the test using Jackson 2.9.9.1 is:
com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "ownerUid": com.example.rest.server.RestServerJacksonModuleTest$TestBeanWithAnnotationsAndDeprecation#getOwnerUid(0 params) vs com.example.rest.server.RestServerJacksonModuleTest$TestBeanWithAnnotationsAndDeprecation#getAccountOwnerUid(0 params)
The difference between running the test with the parameter names module is that
_renameProperties
inPOJOPropertiesCollector
decides that the property needs to be renamed. The breakpoint in there is not hit without the parameter names module being registered with the ObjectMapper.The text was updated successfully, but these errors were encountered: