[API] Fix ErrorProne warnings in API module#5190
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.
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).