Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/src/main/scala/org/apache/spark/TestUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ private[spark] object TestUtils {
val result = new File(fileName)
if (!result.exists()) throw new Exception("Compiled file not found: " + fileName)
val out = new File(destDir, fileName)
result.renameTo(out)

// renameTo cannot handle in and out files in different filesystems
// use google's Files.move instead
Files.move(result, out)

if (!out.exists()) throw new Exception("Destination file not moved: " + out)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny comment: it would be nicer to assert that the file exists, or else throw IOException at least and not Exception. The existing instance of Exception above could also be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review. I am considering using assert with message.
The message will contain the absolute path of file. The absolute path
will give more information. what do you think?

assert(out.exists(),"Destination file not moved: " + out.getAbsolutePath())

out
}
}