Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/577#discussion_r17704914
--- Diff: core/src/main/scala/org/apache/spark/storage/DiskStore.scala ---
@@ -73,7 +73,21 @@ private[spark] class DiskStore(blockManager:
BlockManager, diskManager: DiskBloc
val startTime = System.currentTimeMillis
val file = diskManager.getFile(blockId)
val outputStream = new FileOutputStream(file)
- blockManager.dataSerializeStream(blockId, outputStream, values)
+ try {
+ try {
+ blockManager.dataSerializeStream(blockId, outputStream, values)
+ } finally {
+ outputStream.close()
+ }
+ } catch {
+ case e: Throwable => {
+ if(file.exists()) {
+ file.delete()
+ }
+ throw e
+ }
+ }
--- End diff --
The previous codes are:
```scala
1 try {
2 blockManager.dataSerializeStream(blockId, outputStream, values)
3 outputStream.close()
4 } catch {
5 case e: Throwable => {
6 outputStream.close()
7 if(file.exists()) {
8 file.delete()
9 }
10 throw e
11 }
12 }
```
My concern is if L6 outputStream.close() throws an exception,
`if(file.exists()) { file.delete() }` won't be executed. So I changed to the
nested `try`s.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]