From 295bcff85156921c8eea2904b1d9f883d41f6d1d Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Thu, 7 Dec 2017 01:50:42 +0100 Subject: [PATCH] Hash calculation may throw exception w/ getModifiedTime(); fix In Eval there is a calculation of hashes by scanning the elements of classpath, and getting the last modification time of each directory. When lastModified() was in use, non-existent elements would return 0L, but getModifiedTime() will throw an exception instead (like getLastModifiedTime(), incidentally). So, we catch the FileNotFoundException and return 0L now as well. --- main-actions/src/main/scala/sbt/compiler/Eval.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main-actions/src/main/scala/sbt/compiler/Eval.scala b/main-actions/src/main/scala/sbt/compiler/Eval.scala index 5620306e3..a628e5959 100644 --- a/main-actions/src/main/scala/sbt/compiler/Eval.scala +++ b/main-actions/src/main/scala/sbt/compiler/Eval.scala @@ -487,8 +487,12 @@ private[sbt] object Eval { if (fs eq null) filesModifiedBytes(Array[File]()) else seqBytes(fs)(fileModifiedBytes) def fileModifiedBytes(f: File): Array[Byte] = (if (f.isDirectory) filesModifiedBytes(f listFiles classDirFilter) - else bytes(getModifiedTime(f))) ++ - bytes(f.getAbsolutePath) + else + bytes(try { + getModifiedTime(f) + } catch { + case _: java.io.FileNotFoundException => 0L + })) ++ bytes(f.getAbsolutePath) def fileExistsBytes(f: File): Array[Byte] = bytes(f.exists) ++ bytes(f.getAbsolutePath)