Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/577#discussion_r17701696
--- 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 --
Hm I'm still not so sure about having the nested `try`s. Doesn't this also
affect other changes made in this PR? I think it might be OK to just keep the
close in both `try` and `catch` and have only 1 level of `try-catch`. It's
already strictly better than before (maybe others disagree).
---
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]