Skip to content

Conversation

pjfanning
Copy link
Member

@pjfanning pjfanning commented Mar 13, 2023

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

@pjfanning pjfanning requested a review from cowtowncoder March 13, 2023 23:37
return (throwable instanceof VirtualMachineError
|| throwable instanceof ThreadDeath
|| throwable instanceof InterruptedException
|| throwable instanceof LinkageError);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

@cowtowncoder
Copy link
Member

Ok. I guess that's fine, except for my concern wrt LinkageError.

But how about adding convenience method of rethrowIfFatal(t) to reduce boilerplate code on caller?

@JooHyukKim
Copy link
Member

JooHyukKim commented Mar 13, 2023

But how about adding convenience method of rethrowIfFatal(t) to reduce boilerplate code on caller?

I was about to suggest the same thing 😂. +1 from me. I like the logic inside `isFatal. It seems safer than other way around.

@pjfanning
Copy link
Member Author

Ok. I guess that's fine, except for my concern wrt LinkageError.

But how about adding convenience method of rethrowIfFatal(t) to reduce boilerplate code on caller?

I've refactored to use rethrowIfFatal(t).

I still haven't changed LinkageError.

@pjfanning
Copy link
Member Author

I've changed the 'fatal' check to ignore NoClassDefError

@cowtowncoder
Copy link
Member

Ok looks good. Will merge.

@cowtowncoder cowtowncoder merged commit 5e09ebb into FasterXML:2.15 Mar 14, 2023
@pjfanning pjfanning deleted the exception-util branch March 14, 2023 00:46
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