Skip to content
Snippets Groups Projects
Commit 69b6fed2 authored by baishuo's avatar baishuo Committed by Michael Armbrust
Browse files

[SPARK-4663][sql]add finally to avoid resource leak

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
parent e75e04f9
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment