Skip to content
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

@JacksonInject causes deserialization failure (unresolved forward reference) #639

Open
cowwoc opened this issue Nov 28, 2014 · 3 comments
Open
Labels
has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue

Comments

@cowwoc
Copy link

cowwoc commented Nov 28, 2014

Jackson 2.4.4 is able to successfully deserialize forward references, but it fails to do so if the constructor contains a @JacksonInject parameter.

@cowwoc
Copy link
Author

cowwoc commented Nov 28, 2014

@cowwoc cowwoc changed the title Support mixing forward references with @JacksonInject @JsonInject causes deserialization failure (unresolved forward reference) Dec 19, 2014
@cowtowncoder
Copy link
Member

Actually I think this is different, and bit trickier. Problem is that there is an actual cycle from deserializer perspective, since parent2 may not be constructed before all JSON for it (and its descendants) are consumed; but its child child2 needs parent reference passed via constructor. So the solution here would be to remove @JsonCreator on child2 with non-creator alternative.

Except that in theory, since parent2 only needs injectable value, perhaps implementing #1268 would allow this to be handled even without removing of @JsonCreator.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 19, 2016

So, the json output here is something like:

{"@id":1,"child":{"@id":2,"parent":1}}

and the reason this can not be resolved at this point is only partially due to @JacksonInject. The underlying problem is that neither Parent2 nor Child2 may be constructed before all data is available, as both have @JsonCreator annotated constructor.
Now, in theory Jackson could notice that the only parameter for Parent2 is injectable and create it immediately -- however, before #1381 is implemented, there is no way to indicate that something is purely injectable, that is, something that only comes via injection and not data. With #1268 it should be possible to define this, and with that, this problem would be solvable theoretically.

cowtowncoder added a commit that referenced this issue Jul 19, 2016
@cowtowncoder cowtowncoder changed the title @JsonInject causes deserialization failure (unresolved forward reference) @JacksonInject causes deserialization failure (unresolved forward reference) Mar 30, 2017
@cowtowncoder cowtowncoder added 2.10 and removed 2.9 labels Sep 12, 2019
@cowtowncoder cowtowncoder added 2.12 and removed 2.10 labels Apr 12, 2020
@cowtowncoder cowtowncoder added 2.13 has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue and removed 2.12 labels Oct 27, 2020
@cowtowncoder cowtowncoder added 2.14 and removed 2.13 labels Jul 15, 2021
@cowtowncoder cowtowncoder removed the 2.14 label Mar 2, 2024
cowtowncoder added a commit that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue
Projects
None yet
Development

No branches or pull requests

2 participants