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

[WIP] Create UnsafeNonFatal for use in the fiber runtime #4263

Draft
wants to merge 1 commit into
base: series/3.6.x
Choose a base branch
from

Conversation

kapunga
Copy link
Contributor

@kapunga kapunga commented Jan 31, 2025

Creates a custom NonFatal type for use in the fiber runtime. This is needed because while application code generally shouldn't catch InterruptedException, the fiber runtime is responsible for dealing with interrupts gracefully.

Initially I considered naming this RuntimeNonFatal, however I think UnsafeNonFatal makes it really clear that you shouldn't use it without knowing what you are doing.

Will resolve #4254

@armanbilge
Copy link
Member

Thanks for the PR!! Sorry, would you mind re-targeting to the series/3.6.x branch so we can get it into the 3.6.0 release? 🙏

@kapunga kapunga force-pushed the 4254-custom-non-fatal branch from 569d1c9 to ee6f0b8 Compare February 1, 2025 03:51
@kapunga kapunga changed the base branch from series/3.x to series/3.6.x February 1, 2025 03:52
@kapunga
Copy link
Contributor Author

kapunga commented Feb 1, 2025

Thanks for the PR!! Sorry, would you mind re-targeting to the series/3.6.x branch so we can get it into the 3.6.0 release? 🙏

Done.

@kapunga kapunga force-pushed the 4254-custom-non-fatal branch from 3970f74 to 58a9c5d Compare February 1, 2025 04:15
* code, as handling interrupts gracefully is the responsibility of the runtime, so
* [[UnsafeNonFatal]] should only be used in the fiber runtime.
*/
object UnsafeNonFatal {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be public?

/**
* Returns Some(t) if RuntimeNonFatal(t) == true, otherwise None
*/
def unapply(t: Throwable): Option[Throwable] = Some(t).filter(apply)
Copy link
Contributor

Choose a reason for hiding this comment

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

If t is considered fatal, I think we shouldn't allocate a new object (it could be, e.g., an OutOfMemoryError).

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

Successfully merging this pull request may close these issues.

Use our own NonFatal exception classifier
3 participants