HIVE-29302: Wider Tez session open scope should be guarded to prevent local resource leaks
What changes were proposed in this pull request?
Encapsulate a wider code path in error-handling while opening a Tez session. The point of the patch is nothing more than refactoring code to a separate method:
try {
openInternalUnsafe(isAsync, console);
} catch (Exception e) {
LOG.info("Failed to open session, deleting scratch dir to prevent resource leak...", e);
cleanupScratchDir();
throw e;
}
Why are the changes needed?
A scratch directory can leak if an exception is thrown after it’s created and resources have been placed into it.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test added.
Quality Gate passed
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
not about to handle this:
[Either log this exception and handle it, or rethrow it with some contextual information.](https://sonarcloud.io/project/issues?pullRequest=6161&open=AZpLt4QCPQuC7unSj798&id=apache_hive)
no more useful contextual information can be added here than "hey, I caught this exception, cleaned up, and now re-throwing the session open failure exception"
Changes makes sense to me, to cleanup scratch directory in case of exception before startSessionAndContainers() in openInternal() method
LGTM +1 (non-binding)
thanks @deniskuzZ , @Aggarwal-Raghav for the reviews! restarted test to have a green precommit, then I'll merge
Quality Gate passed
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code