This is an automated email from the ASF dual-hosted git repository.

srowen pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 82765a8  [SPARK-38305][CORE] Explicitly check if source exists in 
unpack() before calling FileUtil methods
82765a8 is described below

commit 82765a826b41311bd3cea2bc454f89ebdc0a3aa1
Author: Sean Owen <sro...@gmail.com>
AuthorDate: Fri Feb 25 08:34:04 2022 -0600

    [SPARK-38305][CORE] Explicitly check if source exists in unpack() before 
calling FileUtil methods
    
    ### What changes were proposed in this pull request?
    
    Explicitly check existence of source file in Utils.unpack before calling 
Hadoop FileUtil methods
    
    ### Why are the changes needed?
    
    A discussion from the Hadoop community raised a potential issue in calling 
these methods when a file doesn't exist.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Existing tests
    
    Closes #35632 from srowen/SPARK-38305.
    
    Authored-by: Sean Owen <sro...@gmail.com>
    Signed-off-by: Sean Owen <sro...@gmail.com>
    (cherry picked from commit 64e1f28f1626247cc1361dcb395288227454ca8f)
    Signed-off-by: Sean Owen <sro...@gmail.com>
---
 core/src/main/scala/org/apache/spark/util/Utils.scala | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala 
b/core/src/main/scala/org/apache/spark/util/Utils.scala
index 1643aa6..efe9cc2 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -577,6 +577,9 @@ private[spark] object Utils extends Logging {
    * basically copied from `org.apache.hadoop.yarn.util.FSDownload.unpack`.
    */
   def unpack(source: File, dest: File): Unit = {
+    if (!source.exists()) {
+      throw new FileNotFoundException(source.getAbsolutePath)
+    }
     val lowerSrc = StringUtils.toLowerCase(source.getName)
     if (lowerSrc.endsWith(".jar")) {
       RunJar.unJar(source, dest, RunJar.MATCH_ANY)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to