Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jul 7, 2022

Any exception coming from the try-catch block will be swallowed and the user will only see the exception from the finally block.
Note that cleanupMetadataAndUnlock() is being called from a finally block.

It seems enough to just log the error but not throw an exception when
metadata cleanup failed.

Any exception coming from the try-catch block will be swallowed and the user will only see the exception from the finally block.
Note that `cleanupMetadataAndUnlock()` is being called from a `finally` block.

It seems enough to just log the error but not throw an exception when
metadata cleanup failed.
} catch (RuntimeException e) {
LOG.error("Fail to cleanup metadata file at {}", newMetadataLocation, e);
throw e;
LOG.error("Failed to cleanup metadata file at {}", newMetadataLocation, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you consider adding e as a "suppressed" exception to any previous exception?

It's a bit more refactoring, but often having more information in the thrown exception is more useful than logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that might be a good option. Let's see what others think

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this option as well. As we lose the CommitFailedException, other than the log... but the exception is the most likely thing to be seen.

But I'd personally wait a bit to see if we hear from somebody at AWS.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine. If it were easier, I'd opt to suppress the exception (maybe we should consider using runSafely for that) but since this is just warning that a file wasn't cleaned up, the important thing is not to throw.

@rdblue rdblue merged commit d3953cf into apache:master Jul 12, 2022
@nastra nastra deleted the dont-throw-from-finally-block branch July 13, 2022 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants