Github user XuefengWu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3293#discussion_r20418956
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -759,18 +759,9 @@ private[spark] object Utils extends Logging {
         if (file != null) {
           try {
             if (file.isDirectory && !isSymlink(file)) {
    -          var savedIOException: IOException = null
    -          for (child <- listFilesSafely(file)) {
    -            try {
    -              deleteRecursively(child)
    -            } catch {
    -              // In case of multiple exceptions, only last one will be 
thrown
    -              case ioe: IOException => savedIOException = ioe
    -            }
    -          }
    -          if (savedIOException != null) {
    -            throw savedIOException
    -          }
    +          listFilesSafely(file).map(child => 
Try(deleteRecursively(child))).
    --- End diff --
    
    But if listFilesSafely return a lazy list, the current code doest not work 
too. the scala for comprehension is only a sugar, it is same as `map` if there 
is one iterator.
    so 
    `
    for (child <- listFilesSafely(file)) {
                try {
                  deleteRecursively(child)
                } catch {
                  // In case of multiple exceptions, only last one will be 
thrown
                  case ioe: IOException => savedIOException = ioe
                }
              }
    `
    is the same as 
    `
    listFilesSafely(file).map{child =>
                try {
                  deleteRecursively(child)
                } catch {
                  // In case of multiple exceptions, only last one will be 
thrown
                  case ioe: IOException => savedIOException = ioe
                }
              }
    `
    the `savedIOException` always be null.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to