-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x Improve coverage, fix bugs #4430
Conversation
Current coverage is 70.49% (diff: 60.29%)@@ 2.x #4430 diff @@
==========================================
Files 454 454
Lines 32340 32371 +31
Methods 0 0
Messages 0 0
Branches 5217 5223 +6
==========================================
+ Hits 22481 22820 +339
+ Misses 7663 7422 -241
+ Partials 2196 2129 -67
|
if (ex instanceof Error) { | ||
throw (Error)ex; | ||
} | ||
if (ex instanceof RuntimeException) { |
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.
wrap
handles this case
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.
The reason I inlined these here is because if I'm using propagate
, that shows up in the code coverage analysis: the throw Exceptions.propagate(ex)
never returns properly and thus the coverage thinks a code path is not covered. It is usually the last roadblock to a 100% covered file. I've been thinking about having ExceptionHelper.wrapOrThrow()
that throws for non-checked and returns a wrapped checked that will run through throw.
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.
Sounds good to me. These exception helper methods could always return an unchecked exception forcing you to use throw
and ensuring code coverage catches it.
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.
Er, I guess that doesn't work for Error
actually.
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.
public static RuntimeException wrapOrThrow(Throwable error) {
if (error instanceof Error) {
throw (Error)error;
}
if (error instanceof RuntimeException) {
return (RuntimeException)error;
}
return new RuntimeException(error);
}
👍 |
Updated those in the first commit in this PR and all other places that used |
Looks good |
The new tests revealed some bugs (nothing major).