-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Do not catch and ignore fatal exceptions #3827
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
Conversation
return (throwable instanceof VirtualMachineError | ||
|| throwable instanceof ThreadDeath | ||
|| throwable instanceof InterruptedException | ||
|| throwable instanceof LinkageError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure LinkageError
should be included in this list: isn't it one of failures that specifically can occur on various platforms trying to load optional extensions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't be against removing LinkageError here or being specific. Some LinkageErrors seem more fatal than others - see the subclasses here - https://docs.oracle.com/javase/7/docs/api/java/lang/LinkageError.html
NoClassDefError seems least fatal but in use cases where I added this util to be used, we tend to have the Class already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the concern I have is specifically that the optional loading should not die on missing classes; that's pretty much the main use case. I wish actual test case. But conversely I haven't seen reports where catching one of fatal errors here have been problematic -- theoretically I could see InterruptedException
catching being problematic, of these I think.
Ok. I guess that's fine, except for my concern wrt But how about adding convenience method of |
I was about to suggest the same thing 😂. +1 from me. I like the logic inside `isFatal. It seems safer than other way around. |
I've refactored to use I still haven't changed LinkageError. |
I've changed the 'fatal' check to ignore NoClassDefError |
src/main/java/com/fasterxml/jackson/databind/util/ExceptionUtil.java
Outdated
Show resolved
Hide resolved
Ok looks good. Will merge. |
I was pitching for this in #3826
I don't think it is a good idea to risk messing with fatal errors like OutOfMemoryErrors.
If this util seems ok, it could in theory be moved to jackson-core and used in other Jackson modules.
fyi @JooHyukKim