-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
"Conflicting setter definitions for property" exception for Map
subtype during deserialization
#2757
Comments
@fschmager First of all, thank you for reporting the issue. Without looking deeply into the problem, I do not see immediate cause in the specific change, nor would there be reason to change it. My first reaction is that since all 3 If this was during serialization, I would accept that it would be irrelevant (no setters used), but the way Jackson handles deserialization there is a requirement that one and exactly one mutator (field, setter, constructor parameter) is used.
but other than that, there is no logic to try to guess which setter to select. So. I am surprised this did not fail with 2.10.x; and am not sure how else this could be handled. |
@cowtowncoder I'm with you. Your explanations make total sense. Jackson just can't know which mutator to use. I've just created a sample project trying to round-trip a few objects with multiple overloaded setters, I feel like I'm already at stage 6 of debugging: How did that ever work? I'm going back to my project where "it used to work" (or me thinking it did) to debug a bit more with |
@fschmager thank you. Regressions like this are always regrettable; let me know what you find. For what it is worth, the idea of allowing pluggable conflict resolvers has been floating around for a while, but I've always postponed it with "should be part of that bigger rewrite of introspection I will for [some future version]". |
Now that was fun, but I think I figured "it" out. How did this ever work
Jackson determines that the
which means when an object mapper reads the value it uses a DiscussionThe behavior of Despite I'm not sure how this should be fixed, but How does Spring use
|
Ohhhh. Very interesting -- thank you for digging this up. It does sound like regression, but obviously I'll need to do some more digging too. That said, it should still work consistently across versions, using as similar heuristics as possible. I'll have to figure out how to reproduce this without adding spring dependency. I can probably add test dep temporarily, then try to strip type definition down to minimal core. As to indexing part: I don't think is is naive, but rather it sounds like problem is a side-effect of introspection that is done for information that turns out not to be needed -- "getter" is simply requested to find aggregated annotation definitions (to find index), but asking for getter then triggers pruning/validation. This calculation is not needed for Maps, but depending on how eagerly/lazily it is done, it may be deferred just enough not to be needed. |
Interesting note: if I first deserialize, THEN ask Actually. This seems to fail sometimes, pass at other times... so is not even stable. Even more fun. |
Looks like I can reproduce this with a simplified version; oddly it is bit sensitive on naming of setters (possibly depends on certain ordering of conflicting methods?). |
Some more background info: attempts to find properties are not entirely irrelevant wrt So figuring out how to make it all work is bit delicate... |
Ok, one possibly simple approach would be to simply not sort properties if deserializing: order should only matter with serialization. Adding a check in |
Ah. The one case I did miss -- but that unit tests did not! -- is the POJO-as-array case. Back to Ye Old Drawing Board. |
Still trying to figure out what to do here: problem is tricky. But I did find one work-around as the problem is triggered by creation of
and registered it using mix-in annotations
will prevent this failure. |
Map
type during properties discovery
Map
type during properties discoveryMap
type during deserialization
Map
type during deserializationMap
subtype during deserialization
Was able to fix this for 2.11.1; not super happy with the way it is handled but works around the issue. I have a feeling similar issues may crop up later on but we'll see. |
Hello, I am facing the same issue while upgrading to Spring Boot 2.3. I am using Kafka in one project where the same error happens with deserializing HttpHeaders sent via Kafka topic. I've tried upgrading to jackson-databind 2.11.1, but no changes. Also tried to downgradre to 2.10.4(and couple more small versions back) as mentioned by issue author, but issue does not disappear. Any suggestions? |
@redasu I would suggest you try to reproduce the issue with a stand-alone test, to ensure that specific Jackson version is used, but with |
I noticed this issue with v2.11.0. I tried 2.11.1 and then 2.11.2, and curiously those two simply changed which property to report the error on. When I finally tried 2.11.3, my test case passed. |
This bug is back on v2.12.6:
|
@bratwurzt this may look similar but it is probably not exactly the same as the regression test added with the fix ( |
I've been deserializing Spring's
HttpHeaders
without issue until I upgraded to latests Spring2.3.0
which upgraded Jackson from2.10.3
to2.11
.After the upgrade to Jackson
2.11
I get this exception when trying to deserialize anHttpHeaders
object:(same can happen for
lastModified
or any other overloaded setter)There are 3
setDate
methods onHttpHeaders
.It's throw as part of
POJOPropertyBuilder#getSetter()
I've traced it back to this change in POJOPropertiesCollector as part of #2555
I couldn't find any way to disable indexing. #2555 is hinting that there isn't one:
I'm wondering if the indexing change broke backward compatibility.
Version exhibiting behavior:
2.11
Last working version (that I tried):
2.10.4
The text was updated successfully, but these errors were encountered: