[NO ISSUE][HYR][MISC] += invocation helpers for unchecked exceptions

Ext-ref: MB-62442
Change-Id: I3b36376e51dbed8915c9bc32963a4243852879cf
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18399
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
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 f4b6e20..c50c6b5 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
@@ -39,6 +39,8 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import com.google.common.util.concurrent.UncheckedExecutionException;
+
 public class InvokeUtil {
 
     private static final Logger LOGGER = LogManager.getLogger();
@@ -357,6 +359,26 @@
         throw HyracksDataException.create(new InterruptedException());
     }
 
+    public static Exception unwrapUnchecked(UncheckedExecutionException e) {
+        Throwable cause = e.getCause();
+        if (cause instanceof Error err) {
+            throw err;
+        } else if (cause instanceof Exception ex) {
+            return ex;
+        } else {
+            return HyracksDataException.create(cause);
+        }
+    }
+
+    public static HyracksDataException unwrapUncheckedHyracks(UncheckedExecutionException e) {
+        Throwable cause = e.getCause();
+        if (cause instanceof Error err) {
+            throw err;
+        } else {
+            return HyracksDataException.create(cause);
+        }
+    }
+
     @FunctionalInterface
     public interface IFailedAttemptCallback {
         void attemptFailed(ComputingAction<?> action, int attempt, boolean isFinal, Span span, Throwable failure);
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java
index 28f5e29..9389953 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java
@@ -18,7 +18,26 @@
  */
 package org.apache.hyracks.util;
 
+import java.util.function.Supplier;
+
+import com.google.common.util.concurrent.UncheckedExecutionException;
+
 @FunctionalInterface
 public interface ThrowingSupplier<T> {
     T get() throws Exception;
+
+    @SuppressWarnings("Duplicates")
+    static <T> Supplier<T> asUnchecked(ThrowingSupplier<T> supplier) {
+        return () -> {
+            try {
+                return supplier.get();
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new UncheckedExecutionException(e);
+            } catch (Exception e) {
+                throw new UncheckedExecutionException(e);
+            }
+        };
+    }
+
 }