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

Make various classes catch Exception instead of RuntimeException even when only RuntimeException is theoretically possible. #6859

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link
Contributor

@copybara-service copybara-service bot commented Dec 4, 2023

Make various classes catch Exception instead of RuntimeException even when only RuntimeException is theoretically possible.

In fact, because checked exceptions are a Java-source-language feature (rather than a JVM feature), it's possible to throw them when you're not "supposed to," either through tricky Java code or more naturally through other languages, such as Kotlin.

We have seen this happening a few times in tests. This causes exceptions to slip past the catch blocks that are meant to handle them. This could cause operations to hang, such as when one listener of a ListenableFuture throws an exception, preventing subsequent listeners (such as a listener that powers Futures.transform) from running.

I didn't cover every catch (RuntimeException ...) block in our codebase, but I tried to get the ones that looked most likely to be affected.

RELNOTES=Changed various classes to catch Exception instead of RuntimeException even when only RuntimeException is theoretically possible.

…even when only `RuntimeException` is theoretically possible.

In fact, because checked exceptions are a Java-source-language feature (rather than a JVM feature), it's possible to throw them when you're not "supposed to," either through tricky Java code or more naturally through other languages, such as Kotlin.

We have seen this happening a few times in tests. This causes exceptions to slip past the `catch` blocks that are meant to handle them. This could cause operations to hang, such as when one listener of a `ListenableFuture` throws an exception, preventing subsequent listeners (such as a listener that powers `Futures.transform`) from running.

I didn't cover _every_ `catch (RuntimeException ...)` block in our codebase, but I tried to get the ones that looked most likely to be affected.

RELNOTES=Changed various classes to catch `Exception` instead of `RuntimeException` even when only `RuntimeException` is theoretically possible.
PiperOrigin-RevId: 587705182
@copybara-service copybara-service bot changed the title Internal change. Make various classes catch Exception instead of RuntimeException even when only RuntimeException is theoretically possible. Dec 4, 2023
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.

None yet

1 participant