Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/577#discussion_r17617974
--- 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 --
I think what you had was actually clearer before. Nested `try`s is a little
more complicated. If you were worried about the 1 line duplicate code then
maybe you can just add a comment to explain that "outputStream should closed
before file is delete" or something.
---
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]