[NO ISSUE][MISC] Preserve Error instances on retryUntilSuccessOrExhausted
Prior to this change, InvokeUtil.retryUntilSuccessOrExhausted() would wrap instances of
java.lang.Error with HyracksDataException upon exhaustion of retry attempts. Errors are
typically handled differently than non-Errors, so preserve the Error when propagating
the failure to the caller.
Change-Id: Idfe1d443addaed342b0c0ed3a0a3835ad226dbe7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11483
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
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 0b1c5a6..7d04cf2 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
@@ -280,6 +280,9 @@
long delayMs = delay.calculate(attempt);
if (!policy.retry(th) || span.elapsed() || span.remaining(TimeUnit.MILLISECONDS) < delayMs) {
onFailure.attemptFailed(action, attempt, true, span, failure);
+ if (th instanceof Error) {
+ throw (Error) th;
+ }
throw HyracksDataException.create(failure);
} else {
onFailure.attemptFailed(action, attempt, false, span, failure);