-
-
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
[Bug] Jackson attempts to parse injected classes as if it were deserializing them. #3124
Comments
Actually, when attempting to use the solution presented in this comment here on 2465, it succeeded in fixing the issue. I'm going to close this issue now because I'm like 99% sure that it's the same issue. |
@solonovamax yes, was about to suggests that: (a) yes, you are correct in that in some cases introspection may fail for no need and (b) there is an existing report. |
Yeah, I found the report but the setup differed enough that I thought this might be different. |
Yes, the tricky thing is that since One possible workaround really is to register bogus deserializer, either by direct registration or mix-in annotations. |
Perhaps instead of having it automatically attempt to parse a deserializer, you need to explicitly tell jackson that the injected value comes from input. (So basically the inverse of the current state. Currently Also, the documentation on |
Yes that is an option, but given that it directly changes existing semantics that would need to go in the next big major version, Jackson 3.0. As to Javadoc improvements, those are always welcome! |
Bug Report
This bug took me a while to track down, but after misunderstanding what the bug actually was like 6 different times, I eventually figured it out.
Description
When using Jackson to inject values with @JacksonInject, Jackson will attempt to parse the injected class as if it were a bean. It will search for setters and getters, even though it never actually uses the injected class as a bean.
I'm just going to explain that again, because it took be a while to grasp that:
Parsed
.Injected
into classParsed
in the constructor.So
Parsed
's constructor would look like this:Injected
was a constructor parameter but not with getters/setters or public properties. But that's probably Kotlin doing something fancy.@JsonIgnore
, then this exception also won't occur.Injected
for any getters/setters.Injected
has two methods that Jackson would interpret as having "conflicting setter definitions", then it will throw an exception.Even though it never actually injects any json into the parsed
Injected
class.Here are two methods which would trigger an exception:
Injected
.They can also be in an exposed property of
Injected
.Version Information
This occurs on Jackson version
2.12.3
, pulled from Maven Central.To Reproduce
Steps to reproduce the behaviour:
Here is a test class for the bug: (Yeah, I know it's big. I wrote a bunch of comments because I found it kind of hard to initially understand what was going on)
Expected behavior
When injecting
Injected
intoParsed
, Jackson should not attempt to processClassThatBreaks
for setters/getters.The way I originally found this issue was by injecting a class which contained a reference to an
ObjectMapper
,and it was failing because of two clashing definitions of
ObjectMapper#setDefaultPropertyInclusion
.Additional Context
This may be similar to #2465, but I'm not entirely sure.
I do believe that this is something different, though.
The text was updated successfully, but these errors were encountered: