[
https://issues.apache.org/jira/browse/HIVE-22060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16897128#comment-16897128
]
Ivan Suller commented on HIVE-22060:
------------------------------------
[~pvary] There's almost always a way to avoid catching Throwable. For example
I'd write the above issue from this:
{code:java}
try {
...
} catch (Exception e) {
LOG.error("Caught exception while trying to compact " + ci +
". Marking failed to avoid repeated failures, " +
StringUtils.stringifyException(e));
msc.markFailed(CompactionInfo.compactionInfoToStruct(ci));
msc.abortTxns(Collections.singletonList(compactorTxnId));
}
{code}
to this:
{code:java}
boolean successfulCompaction = false;
try {
...
successfulCompaction = true;
} finally {
if (!successfulCompaction) {
msc.markFailed(CompactionInfo.compactionInfoToStruct(ci));
msc.abortTxns(Collections.singletonList(compactorTxnId));
}
} catch (Exception e) {
LOG.error("Caught exception while trying to compact " + ci +
". Marking failed to avoid repeated failures, " +
StringUtils.stringifyException(e));
}
{code}
> Replacing "catch Throwable" with a more restricted exception class
> ------------------------------------------------------------------
>
> Key: HIVE-22060
> URL: https://issues.apache.org/jira/browse/HIVE-22060
> Project: Hive
> Issue Type: Improvement
> Components: Hive
> Reporter: Ivan Suller
> Assignee: Ivan Suller
> Priority: Major
>
> Catching Throwable considered unsafe in Java. A Throwable can be any Error
> and those are JVM errors after the state of the JVM is not guaranteed thus
> the cleanest way to "handle" the error is to let it kill the current thread.
> I ran a quick scan and found almost 400 "catch Throwable" in the current
> codebase. I opened this ticket as a conversation starter to:
> - discuss if we want to eliminate this issue
> - if we want to do it what's the best way to do it
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)