-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Serialize InvalidFormatException cause infinite recursion #1413
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
Comments
i found the issue reason. This is the packed exception struct: // Root InternelServerException
Cause
// Children InvalidFormatException
Cause
StrakTrace
_targetType
StrakTrace
.... let me show the progress of serialize, the key is in InvalidFormatException field _targetType. _targetType is When serialize the _targetType(ObjectMapper) fields, jackson will serialize the _jsonFactory(JsonFactory), then jackson serialize _jsonFactory(JsonFactory) fields, the _objectCodec(ObjectMapper) will be serialized, because it is reference of _targetType, so the endless loop generated! See the below picture: |
So i guess, if two class has reference of each other, then the serialization will be failed. I think it is a terrible problem. Please check this!! |
Can not reproduce with 2.8[.4], assuming fixed, closed. |
@cowtowncoder i checked #1368 patch content, @JsonIgnore added on the field _processor, in this case, the field _targetType is issue, so i think we need add @JsonIgnore on this field also. let me try this version(2.8.3), and then reply here. Thanks! |
@cowtowncoder yes, i try version(2.8.3), no stack overflow, but i am confusing, i dont find the ignore on the field _targetType on InvalidFormatException, how it is be ignored? i debug and find this field is not be serialize. |
@cowtowncoder Ok Ok, i found, i see the wrong field. The issue is in _processor field, not _targetType. Everything is ok now, thanks |
Jackson version: 2.8.1
Hi,
I use jackson as a MessageBodyWriter and MessageBodyReader in jesery framwork. I am doing a
restful application. But I meet a terrible issue when i get InvalidFormatiotException and convert it
to a response,
Infinite recursion (StackOverflowError)
error reporting!have ignored very long repeat information.
I have a POJO:
In normal situation, i transfer a normal json like
{"post_id": 1, "post_title": "test"'}
(I want to update a post), it works fine. But when i transfer a type mismatch json like
{"post_id": "test", "post_title": "test"'}
, the terrible situation appeared.I have a exception mapper to mapper a exception to a response, so in this case, when the type
is mismatch, jackson will occur a InvalidFormatException:
And then i use a InternalServerException to pack this exception, and then set response entity by
using this new exception:
Then, as you see, the infinite recursion appeared. Why i get this terrible error? If i dont pack the
InvalidFormatException and use another exception to wrap the response entity, every thins is ok!
Hopeful to get the reply, i debugged whole day, StackOverFlow is really a disaster.
Thanks
The text was updated successfully, but these errors were encountered: