-
Notifications
You must be signed in to change notification settings - Fork 3k
[API] Fix ErrorProne warnings in API module #5190
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
Conversation
|
The 1 remaining error prone warning in API module requires a bit more caution when / if we adjust it as this function in |
|
Re: https://github.com/apache/iceberg/blob/master/api/src/main/java/org/apache/iceberg/util/ExceptionUtil.java#L124 it does look like the most recent exception ( Perhaps that line should do |
|
I agree with @dimas-b's comment. Let's switch from |
|
If there are multiple exceptions, then I think we should add the one that isn't thrown as a suppressed exception on the one that we do throw. |
|
Looks like this can be closed as these were fixed in: #5200 Thanks all! |
64a8568 to
83525ba
Compare
|
Switching from throwing And we're trying to throw iceberg/api/src/main/java/org/apache/iceberg/util/ExceptionUtil.java Lines 117 to 124 in d563d6d
So it looks like we need to change to throwing |
| tryThrowAs(failure, e1Class); | ||
| tryThrowAs(failure, e2Class); | ||
| tryThrowAs(failure, e3Class); | ||
| tryThrowAs(failure, RuntimeException.class); | ||
| throw new RuntimeException("Unknown throwable", failure); |
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.
This seems like it will fix what the warning is about, that throwing from a finally block will swallow whatever is returned or thrown inside of the try block.
So this repeats lines 105-109, where we attempt to throw failure after running the catch block. As the warning message from error prone says that it will get swallowed if we throw inside of the finally, but we did try to throw it inside of the catch block.
Though I think this also changes the semantics of the function as intended. So maybe we should just add the suppression?
This seems to happen already on line 118, but we're not rethrowing it from within the finally block (which is what the warning message is mentioning if I'm not mistaken): I've added rethrowing iceberg/api/src/main/java/org/apache/iceberg/util/ExceptionUtil.java Lines 105 to 118 in d563d6d
|
|
I just noticed that none of these Maybe we ought to either remove them or mark them as deprecated? |
6ced16c to
83525ba
Compare
|
I reverted the changes to |
The number of error prone warnings has slowly gotten somewhat higher.
This PR fixes all of the relatively simple error prone warnings for the API module, which will have API / ABI compatibility guarantees come the 1.0 release (and so the JavaDocs should hopefully be stable from then on).