Skip to content

Commit

Permalink
add finally to avoid resource leak
Browse files Browse the repository at this point in the history
  • Loading branch information
baishuo committed Dec 1, 2014
1 parent e678b9f commit ae0e447
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,15 @@ 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)
return 1
}
Expand Down

0 comments on commit ae0e447

Please sign in to comment.