ASTERIXDB-1002: Fix exception handling in EmptyTupleSourceRuntimeFactory
Change-Id: Ibc9da24ceca87c6a8ec4bae16a0579312c27b668
Reviewed-on: https://asterix-gerrit.ics.uci.edu/416
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/EmptyTupleSourceRuntimeFactory.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/EmptyTupleSourceRuntimeFactory.java
index b5d717a..5b66736 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/EmptyTupleSourceRuntimeFactory.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/EmptyTupleSourceRuntimeFactory.java
@@ -49,13 +49,15 @@
@Override
public void open() throws HyracksDataException {
writer.open();
- if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
- throw new IllegalStateException();
+ try {
+ if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
+ throw new IllegalStateException();
+ }
+ appender.flush(writer, true);
+ } finally {
+ writer.close();
}
- appender.flush(writer, true);
- writer.close();
}
};
}
-
}