[NO ISSUE][HYR] Don't suppress errors, check interrupted exceptions

Avoid suppressing instances of Error into a HyracksDataException,
instead rethrow it.  Check when suppressing an InterruptedException that
the calling thread is itself interrupted, otherwise emit a warning

Change-Id: I9784a18aaaed93e16078437b1cff5006e2a33861
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2095
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
index 2cf804e..4517730 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
@@ -40,6 +40,7 @@
             // don't wrap errors, allow them to propagate
             throw (Error)cause;
         } else if (cause instanceof InterruptedException && !Thread.currentThread().isInterrupted()) {
+            // TODO(mblow): why not force interrupt on current thread?
             LOGGER.log(Level.WARNING,
                     "Wrapping an InterruptedException in HyracksDataException and current thread is not interrupted",
                     cause);
@@ -59,6 +60,15 @@
         if (root == null) {
             return HyracksDataException.create(th);
         }
+        if (th instanceof Error) {
+            // don't suppress errors into a HyracksDataException, allow them to propagate
+            th.addSuppressed(root);
+            throw (Error) th;
+        } else if (th instanceof InterruptedException && !Thread.currentThread().isInterrupted()) {
+            // TODO(mblow): why not force interrupt on current thread?
+            LOGGER.log(Level.WARNING, "Suppressing an InterruptedException in a HyracksDataException and current "
+                    + "thread is not interrupted", th);
+        }
         root.addSuppressed(th);
         return root;
     }