>From Michael Blow <[email protected]>:
Michael Blow has uploaded this change for review. (
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
---
M
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/InvokeUtil.java
1 file changed, 38 insertions(+), 1 deletion(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/79/18779/1
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..481f2e6 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: 1
Gerrit-Owner: Michael Blow <[email protected]>
Gerrit-MessageType: newchange