Skip to content

Fix #4603 (Keep stacktrace when re-throwing exception with JsonMappingException) #5041

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

Closed
wants to merge 3 commits into from

Conversation

JooHyukKim
Copy link
Member

@JooHyukKim JooHyukKim commented Mar 21, 2025

Throwable th = ClassUtil.getRootCause(e);
throw JsonMappingException.from(p, ClassUtil.exceptionMessage(th), th);
} else {
throw JsonMappingException.from(p, ClassUtil.exceptionMessage(e.getCause()), e.getCause());
Copy link
Member Author

@JooHyukKim JooHyukKim Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thougths...

  1. Calling getCause() because exception is InvocationTarget exception thrown from a setter method.
    There maybe other cases? or nah

  2. How to centralize this handling? Or at least make it clean

/**
* @since 2.19
*/
WRAP_EXCEPTIONS(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highly confusing since we already have SerializationFeature.WRAP_EXCEPTIONS and DeserializationFeature.WRAP_EXCEPTIONS...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, will change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified to your original suggestion 👍🏼

@JooHyukKim JooHyukKim marked this pull request as ready for review March 24, 2025 12:29
@JooHyukKim JooHyukKim marked this pull request as draft March 24, 2025 12:36
@JooHyukKim
Copy link
Member Author

@cowtowncoder May I ask what you think of this?
Would it be reasonable to push through this work?
Asking this because it seems next step would be searching for all spots to put in the config.

@cowtowncoder
Copy link
Member

@JooHyukKim Sorry, haven't had time to really think it through.

My initial thinking though is that maybe this should wait for other work -- or ideally getting a test by submitted to ensure we know what exactly is being requested.

I'll try to come back to this one soon & add more useful note wrt what I think.

@cowtowncoder
Copy link
Member

cowtowncoder commented Mar 26, 2025

Quick note/question: #4603 is for Jackson 3.0, not 2.19.

Too risky trying to do this with 2.x, not as much benefit.

@stevenschlansker
Copy link

FWIW, I ran into something like this while working on #5046 - when setAccessible call failed, the exception was wrapped in a Jackson exception and lost the stack trace, which made debugging harder. I had to set a breakpoint in the debugger to find the stack.

@JooHyukKim JooHyukKim changed the base branch from 2.19 to master March 28, 2025 06:36
@JooHyukKim
Copy link
Member Author

Will re-create PR because of some rebase conflicts, to be safe.

@JooHyukKim JooHyukKim closed this Mar 28, 2025
@JooHyukKim
Copy link
Member Author

JooHyukKim commented Mar 28, 2025

#5054 Re-based version

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

Successfully merging this pull request may close these issues.

3 participants