spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mridulm <...@git.apache.org>
Subject [GitHub] spark pull request #16657: [SPARK-19306][Core] Fix inconsistent state in Dis...
Date Fri, 20 Jan 2017 11:32:58 GMT
Github user mridulm commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16657#discussion_r97056028
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/DiskBlockObjectWriter.scala ---
    @@ -206,18 +209,22 @@ private[spark] class DiskBlockObjectWriter(
             streamOpen = false
             closeResources()
           }
    +   } catch {
    +      case e: Exception =>
    +        logError("Uncaught exception while closing file " + file, e)
    +    }
     
    -      val truncateStream = new FileOutputStream(file, true)
    -      try {
    -        truncateStream.getChannel.truncate(committedPosition)
    -        file
    -      } finally {
    -        truncateStream.close()
    -      }
    +    var truncateStream: FileOutputStream = null
    +    try {
    +      truncateStream = new FileOutputStream(file, true)
    +      truncateStream.getChannel.truncate(committedPosition)
    +      file
         } catch {
           case e: Exception =>
             logError("Uncaught exception while reverting partial writes to file " + file,
e)
             file
    +    } finally {
    +      truncateStream.close()
    --- End diff --
    
    Another option is to use `Utils.tryWithSafeFinally` and do the if block with closeResources
in the block with truncate in the finally block


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message