Skip to content

Commit

Permalink
[SPARK-4663][sql]add finally to avoid resource leak
Browse files Browse the repository at this point in the history
Author: baishuo <vc_java@hotmail.com>

Closes #3526 from baishuo/master-trycatch and squashes the following commits:

d446e14 [baishuo] correct the code style
b36bf96 [baishuo] correct the code style
ae0e447 [baishuo] add finally to avoid resource leak
  • Loading branch information
baishuo authored and marmbrus committed Dec 2, 2014
1 parent e75e04f commit 69b6fed
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,14 @@ case class InsertIntoParquetTable(
val committer = format.getOutputCommitter(hadoopContext)
committer.setupTask(hadoopContext)
val writer = format.getRecordWriter(hadoopContext)
while (iter.hasNext) {
val row = iter.next()
writer.write(null, row)
try {
while (iter.hasNext) {
val row = iter.next()
writer.write(null, row)
}
} finally {
writer.close(hadoopContext)
}
writer.close(hadoopContext)
committer.commitTask(hadoopContext)
1
}
Expand Down

0 comments on commit 69b6fed

Please sign in to comment.