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

Using @JsonUnwrapped annotation in builderdeserializer hangs in infinite loop #1978

Closed
roeltje25 opened this issue Mar 21, 2018 · 6 comments
Closed
Milestone

Comments

@roeltje25
Copy link

We are using a builder to deserialize a bean and one of the properties is annotated with a @JsonUnwrapped annotation. The code hangs in BuilderBasedDeserializer.java in method deserializeWithObject in the loop starting on line 307. The code of that loop differs significantly from the code i see in master where the loop starts on line 340. The 2.9.4 version of the loop that I am using hangs as there seems to be no end token. p.nextToken() returns null indicating the last token was consumed but this value is not checked making the loop stuck for eternity...

I guess the code in master improves on the behavior in the 2.9 branch. Perhaps this should be merged to 2.9?

Thanks in advance for any fix.

@cowtowncoder
Copy link
Member

Master is for Jackson 3.0, so simple merging is probably not possible.
But if you have a simple reproduction I could definitely improve handling is applicable.
Test would obviously be valuable against regressions, and is not covered currently (as per your seeing the problem).

@roeltje25
Copy link
Author

Ok.

So I worked a bit to get a minimalistic example. It seems the crucial part is combining:

  • JsonUnwrapped(prefix)
  • Property based creator in builder

Please find attached a zip with all needed files. run the Processor class and it will hang infinitely.

If somebody would let me know how to import databind in eclipse I would have tried to get it into a junit test, but this should illustrate the issue. @
issue-1978-testcase.zip

@cowtowncoder
Copy link
Member

Thank you! I hope to add changes for 2.9.5, sounds like a nasty situation and best avoided :)

@roeltje25
Copy link
Author

roeltje25 commented Mar 22, 2018 via email

@cowtowncoder
Copy link
Member

@roeltje25 What I meant by "best avoided" was reference to infinite-loop occurring, not configuration that (currently) triggers it. Just in case that was ambiguous. So even if there was configuration that couldn't work, it should be signaled with better mechanism.

@cowtowncoder
Copy link
Member

Changed to prevent infinite loop, but I think this is just a side-effect, so created #1979 for hopefully figuring that out. I think buffering is either missing JsonToken.END_OBJECT, or possibly something is advancing tokens incorrectly.
But first things first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants