Skip to content

Commit

Permalink
[SPARK-28912] Fixed MatchError in getCheckpointFiles()
Browse files Browse the repository at this point in the history
  • Loading branch information
avkgh committed Sep 7, 2019
1 parent 6dc209f commit 1a55258
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ object Checkpoint extends Logging {
try {
val statuses = fs.listStatus(path)
if (statuses != null) {
val paths = statuses.map(_.getPath)
val filtered = paths.filter(p => REGEX.findFirstIn(p.toString).nonEmpty)
val paths = statuses.filterNot(_.isDirectory).map(_.getPath)
val filtered = paths.filter(p => REGEX.findFirstIn(p.getName).nonEmpty)
filtered.sortWith(sortFunc)
} else {
logWarning(s"Listing $path returned null")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,26 @@ class CheckpointSuite extends TestSuiteBase with DStreamCheckpointTester
checkpointWriter.stop()
}

test("SPARK-28912: Fix MatchError in getCheckpointFiles") {
val tempDir = Utils.createTempDir()
try {
val fs = FileSystem.get(tempDir.toURI, new Configuration)
val checkpointDir = tempDir.getAbsolutePath + "/checkpoint-01"

assert(Checkpoint.getCheckpointFiles(checkpointDir, Some(fs)).length === 0)

// Ignore files whose parent path match.
fs.create(new Path(checkpointDir, "this-is-matched-before-due-to-parent-path")).close()
assert(Checkpoint.getCheckpointFiles(checkpointDir, Some(fs)).length === 0)

// Ignore directories whose names match.
fs.mkdirs(new Path(checkpointDir, "checkpoint-1000000000"))
assert(Checkpoint.getCheckpointFiles(checkpointDir, Some(fs)).length === 0)
} finally {
Utils.deleteRecursively(tempDir)
}
}

test("SPARK-6847: stack overflow when updateStateByKey is followed by a checkpointed dstream") {
// In this test, there are two updateStateByKey operators. The RDD DAG is as follows:
//
Expand Down

0 comments on commit 1a55258

Please sign in to comment.