Skip to content

Commit

Permalink
Remove unnecessary Semaphore and Future block
Browse files Browse the repository at this point in the history
  • Loading branch information
advancedxy committed Feb 27, 2018
1 parent 88e86e0 commit ba2f355
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions core/src/test/scala/org/apache/spark/JobCancellationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,7 @@ class JobCancellationSuite extends SparkFunSuite with Matchers with BeforeAndAft
executionOfInterruptibleCounter.getAndIncrement()
}

val sem = new Semaphore(0)
val taskCompletedSem = new Semaphore(0)
Future {
taskStartedSemaphore.acquire()
f.cancel()
sem.release()
}

sc.addSparkListener(new SparkListener {
override def onStageCompleted(stageCompleted: SparkListenerStageCompleted): Unit = {
Expand All @@ -368,8 +362,9 @@ class JobCancellationSuite extends SparkFunSuite with Matchers with BeforeAndAft
}
})

// Make sure code in the Future block is finished, a.k.a tasks are being cancelled.
sem.acquire()
taskStartedSemaphore.acquire()
f.cancel()

val e = intercept[SparkException] { f.get() }.getCause
assert(e.getMessage.contains("cancelled") || e.getMessage.contains("killed"))

Expand Down

0 comments on commit ba2f355

Please sign in to comment.