apache/spark — pull request #3186 by sarutak (2014-11-10 19:34:44+00:00)
Title: [SPARK-4323] Utils#fetchFile method should close lock file certainly

In Utils#fetchFile method, lock file is created like as follows.

val raf = new RandomAccessFile(lockFile, "rw")
// Only one executor entry.
// The FileLock is only used to control synchronization for executors download file,
// it's always safe regardless of lock type (mandatory or advisory).
val lock = raf.getChannel().lock()
val cachedFile = new File(localDir, cachedFileName)
try {
if (!cachedFile.exists()) {
doFetchFile(url, localDir, cachedFileName, conf, securityMgr, hadoopConf)
}
} finally {
lock.release()
}

If some error occurs between opening RandomAccessFile and getting lock, lock file can be not closed.