commit | 86f3908ba93090c2546b6887db930d523864b639 | [log] [tgz] |
---|---|---|
author | Michael Blow <mblow@apache.org> | Sun Jun 11 01:45:24 2017 -0400 |
committer | Yingyi Bu <buyingyi@gmail.com> | Sun Jun 11 09:27:39 2017 -0700 |
tree | 89dee028a6be74a8948983a90bff183abebc14ba | |
parent | f0759c85b70d18fe9376cdc034ed9e70e1ec0c74 [diff] |
IFrameWriter.close() can be called if open() failed Fix potential NPE in ResultWriterOperatorDescriptor should open() fail and close() be subsequently called Change-Id: I6f53258765719c30b132bf67680f280924b624be Reviewed-on: https://asterix-gerrit.ics.uci.edu/1832 Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu> BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/result/ResultWriterOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/result/ResultWriterOperatorDescriptor.java index d3120bb..78417ac 100644 --- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/result/ResultWriterOperatorDescriptor.java +++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/result/ResultWriterOperatorDescriptor.java
@@ -117,15 +117,17 @@ @Override public void close() throws HyracksDataException { - try { - if (!failed && frameOutputStream.getTupleCount() > 0) { - frameOutputStream.flush(datasetPartitionWriter); + if (datasetPartitionWriter != null) { + try { + if (!failed && frameOutputStream.getTupleCount() > 0) { + frameOutputStream.flush(datasetPartitionWriter); + } + } catch (Exception e) { + datasetPartitionWriter.fail(); + throw e; + } finally { + datasetPartitionWriter.close(); } - } catch (Exception e) { - datasetPartitionWriter.fail(); - throw e; - } finally { - datasetPartitionWriter.close(); } }