Fixed ExternalSortOperatorDescriptor to work correctly on empty input

git-svn-id: https://hyracks.googlecode.com/svn/trunk@158 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ExternalSortOperatorDescriptor.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ExternalSortOperatorDescriptor.java
index a408d85..228d22b 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ExternalSortOperatorDescriptor.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ExternalSortOperatorDescriptor.java
@@ -193,7 +193,9 @@
                     try {
                         if (runs.size() <= 0) {
                             FrameSorter frameSorter = (FrameSorter) env.get(FRAMESORTER);
-                            frameSorter.flushFrames(writer);
+                            if (frameSorter != null) {
+                                frameSorter.flushFrames(writer);
+                            }
                             env.set(FRAMESORTER, null);
                         } else {
                             inFrames = new ArrayList<ByteBuffer>();