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

    https://github.com/apache/spark/pull/14731#discussion_r97367042
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/dstream/FileInputDStream.scala
 ---
    @@ -196,29 +191,29 @@ class FileInputDStream[K, V, F <: NewInputFormat[K, 
V]](
           logDebug(s"Getting new files for time $currentTime, " +
             s"ignoring files older than $modTimeIgnoreThreshold")
     
    -      val newFileFilter = new PathFilter {
    -        def accept(path: Path): Boolean = isNewFile(path, currentTime, 
modTimeIgnoreThreshold)
    -      }
    -      val directoryFilter = new PathFilter {
    -        override def accept(path: Path): Boolean = 
fs.getFileStatus(path).isDirectory
    -      }
    -      val directories = fs.globStatus(directoryPath, 
directoryFilter).map(_.getPath)
    +      val directories = 
Option(fs.globStatus(directoryPath)).getOrElse(Array.empty[FileStatus])
    --- End diff --
    
    I believe the getOrElse clause should handle the globStatus() return value 
being null, upconverting it to an empty array. Which is essentially working 
backwards from this special (awful) case in Glob code
    ```java
        if ((!sawWildcard) && results.isEmpty() &&
            (flattenedPatterns.size() <= 1)) {
          return null;
        }
    ```
    With the directories now being an empty array, `flatMap()` should 
effectively start with a `map` of the 0-element array, which is will result in 
the`newFiles` value also being empty. Isn't that right?


---
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