Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

core: Avoid wrapping Errors in RuntimeException #2131

Merged
merged 1 commit into from
Aug 4, 2016

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Aug 4, 2016

No description provided.

@@ -56,7 +58,8 @@ public void run() {
task.run();
} catch (Throwable t) {
log.log(Level.SEVERE, "Exception while executing runnable " + task, t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
Throwables.propagateIfPossible(t);
throw new AssertionError(t);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will either be an Exception or a raw Throwable (or a subclass of Throwable that isn't RE or E).

Is wrapping in an AE appropriate?

Copy link
Member Author

Choose a reason for hiding this comment

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

The only classes that are unchecked is RuntimeException and Error (and children). So getting to this line should not be possible (without hacks). So AssertionError seems fitting.

Copy link
Contributor

Choose a reason for hiding this comment

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

This may be dumb, but won't all checked exceptions reach that point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Happened to discuss offline. run() declares no checked exceptions.

@carl-mastrangelo
Copy link
Contributor

LGTM

@ejona86 ejona86 merged commit d394cef into grpc:master Aug 4, 2016
@ejona86 ejona86 deleted the no-wrap-error branch August 4, 2016 21:27
@ejona86 ejona86 added the TODO:backport PR needs to be backported. Removed after backport complete label Aug 4, 2016
@zhangkun83 zhangkun83 removed the TODO:backport PR needs to be backported. Removed after backport complete label Sep 14, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants