>From Murtadha Hubail <[email protected]>: Murtadha Hubail has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18779 )
Change subject: [NO ISSUE][HYR][MISC] += InvokeUtil.runWithCleanupsUnchecked ...................................................................... [NO ISSUE][HYR][MISC] += InvokeUtil.runWithCleanupsUnchecked Ext-ref: MB-63363 Change-Id: Ida57bd21c412fa935c7babaf0ae47e3ea05b4794 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18779 Reviewed-by: Michael Blow <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> --- M hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java 1 file changed, 43 insertions(+), 1 deletion(-) Approvals: Murtadha Hubail: Looks good to me, approved Michael Blow: Looks good to me, but someone else must approve Jenkins: Verified; Verified diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java index c50c6b5..3ed17b1 100644 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java +++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java @@ -213,7 +213,8 @@ } } - @SuppressWarnings({ "squid:S1181", "squid:S1193", "ConstantConditions" }) // catching Throwable, instanceofs + @SuppressWarnings({ "squid:S1181", "squid:S1193", "ConstantConditions", "UnreachableCode" }) + // catching Throwable, instanceofs, false-positive unreachable code public static void tryWithCleanups(ThrowingAction action, ThrowingAction... cleanups) throws Exception { Throwable savedT = null; boolean suppressedInterrupted = false; @@ -287,6 +288,32 @@ } } + public static void tryWithCleanupsUnchecked(Runnable action, Runnable... cleanups) { + Throwable savedT = null; + try { + action.run(); + } catch (Throwable t) { + savedT = t; + } finally { + for (Runnable cleanup : cleanups) { + try { + cleanup.run(); + } catch (Throwable t) { + if (savedT != null) { + savedT.addSuppressed(t); + } else { + savedT = t; + } + } + } + } + if (savedT instanceof Error) { + throw (Error) savedT; + } else if (savedT != null) { + throw new UncheckedExecutionException(savedT); + } + } + /** * Runs the supplied action, after suspending any pending interruption. An error will be logged if * the action is itself interrupted. -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18779 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: goldfish Gerrit-Change-Id: Ida57bd21c412fa935c7babaf0ae47e3ea05b4794 Gerrit-Change-Number: 18779 Gerrit-PatchSet: 3 Gerrit-Owner: Michael Blow <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Hussain Towaileb <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-MessageType: merged
