gaborgsomogyi commented on a change in pull request #25654: 
[SPARK-28912][STREAMING] Fixed MatchError in getCheckpointFiles()
URL: https://github.com/apache/spark/pull/25654#discussion_r321748356
 
 

 ##########
 File path: 
streaming/src/test/scala/org/apache/spark/streaming/CheckpointSuite.scala
 ##########
 @@ -847,6 +847,38 @@ class CheckpointSuite extends TestSuiteBase with 
DStreamCheckpointTester
     checkpointWriter.stop()
   }
 
+  test("SPARK-28912: Fix MatchError in getCheckpointFiles") {
+    val tempDir = Utils.createTempDir()
+    val checkpointDir = tempDir + "/checkpoint-01"
+
+    Utils.deleteRecursively(tempDir)
+
+    val hadoopConf = new Configuration
+    val checkpointWriter =
+      new CheckpointWriter(mock(classOf[JobGenerator]), conf, checkpointDir, 
hadoopConf)
+
+    // Create a fake RDD checkpoint dir to emulate 
SparkContext.setCheckpointDir()
+    val fakeRddPath = new Path(checkpointDir, 
java.util.UUID.randomUUID().toString)
+    fakeRddPath.getFileSystem(hadoopConf).mkdirs(fakeRddPath)
+
+    val checkpointTimes = (1 to 20).map(_ * 1000)
+
+    try {
+      checkpointTimes.foreach(tm => new 
checkpointWriter.CheckpointWriteHandler(
+        Time(tm), Array.fill[Byte](10)(1), clearCheckpointDataLater = 
false).run())
+    } catch {
+      case ex: MatchError => fail("Should not throw MatchError", ex)
+    }
+
+    val expectedCheckpoints = checkpointTimes.takeRight(10).map { tm =>
+      Checkpoint.checkpointFile(checkpointDir, Time(tm)).getName }
+
+    assert(Checkpoint.getCheckpointFiles(checkpointDir).map(_.getName) == 
expectedCheckpoints)
+
+    Utils.deleteRecursively(tempDir)
+    checkpointWriter.stop()
 
 Review comment:
   Would be better in finally block because if anything throws exception then 
checkpointWriter will stay open.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to