-
-
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
Polymorphic subtype deduction ignores defaultImpl
attribute
#3055
Comments
Please assign to me. I'm happy to support my addition :) |
Great! Sounds like this could go in 2.12 branch (might make it in 2.12.2 depending on timing), if it feels like low-risk addition (seems to me that'd be the case). Otherwise should go in 2.13 which would get bit longer to get out. |
See PR #3057. However To discuss: Quality of feedback is reduced I stumbled on (c) as my superclass was abstract (and after that because I had not disabled FAIL_ON_UNKNOWN_PROPERTIES). I can quite imagine users doing similar things and never testing that their defaultImpl works (DEDUCTION mode is after all a little bit of a "lazy model"). I predict confusion as to why Jackson is complaining about a secondary issue and completely masking the original cause (deduction failure). @cowtowncoder next step is your call but I'd rather include what we have here as there's other work to be done in this area |
Hmmh. Yes, I see; while fixing the issue wrt For 2.12 this may be best we could do; for 2.13 callbacks could possibly be improved. For example, could add alternative I suspect that we might be able to solve some of these (esp (a)) with more changes to base impl So with that, @drekbour, do you think splitting improvements b/w 2.12 and 2.13 makes sense? |
I think defaultImpl for both (b) and (c) works the same for other subtype modes does it not? |
@drekbour Yes, So my concern is only about actual fail messages. Those should be adjustable based on "type id type" (resolution mechanism), possibly just having special logic for Deduction type. |
Have updated this PR with a simple change to allow contextual failure reports - reinstating the original text. I have not attempted to write a better report as that would be a separate PR with new discussion (enough here already!). |
@drekbour thanks! That sounds good. Agree, first things first; and for 2.12.x patches fixing missing |
defaultImpl
attribute
Describe the bug
A class with
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, defaultImpl = Animal.class)
that fails to deduce a solo candidate should usedefaultImpl
Version information
2.12.0
To Reproduce
TBA see #2976
Expected behavior
In the absence of a single candidate,
defaultImpl
should be the target type regardless of suitability.Additional context
The current deduction process does not support pojo-hierarchies such that the absence of child properties infers a parent type. That is, every deducible subtype MUST have some unique properties and the input data MUST contain said unique properties to provide a positive match.
The text was updated successfully, but these errors were encountered: