Skip to content

Conversation

@jackye1995
Copy link
Contributor

wrap io().deleteFile(metadataLocation) in try catch block so that unlock(lockId) must be called in the finally block.

@github-actions github-actions bot added the hive label Dec 28, 2020
}
} catch (RuntimeException e) {
LOG.error("Fail to cleanup metadata file at {}", metadataLocation, e);
throw e;

Choose a reason for hiding this comment

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

Not a fan of Throw within a Catch.
Maybe you can wrap it in something else.

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 because we don't want to wrap or modify the original exception, and it is helpful to log the metadata location that was not correctly deleted.

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 we may leverage runSafely that was added recently.

    ExceptionUtil.runSafely(
        () -> {
          if (errorThrown) {
            // if anything went wrong, clean up the uncommitted metadata file
            io().deleteFile(metadataLocation);
          }
          return Void.TYPE;
        },
        e -> LOG.error("Failed to cleanup metadata file at {}", metadataLocation, e),
        () -> unlock(lockId));

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants