diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/org/apache/spark/FutureAction.scala | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/core/src/main/scala/org/apache/spark/FutureAction.scala b/core/src/main/scala/org/apache/spark/FutureAction.scala index 64e354e2e3..9f41912d6c 100644 --- a/core/src/main/scala/org/apache/spark/FutureAction.scala +++ b/core/src/main/scala/org/apache/spark/FutureAction.scala @@ -177,13 +177,11 @@ class CancellablePromise[T] extends FutureAction[T] with Promise[T] { def run(func: => T)(implicit executor: ExecutionContext): Unit = scala.concurrent.future { thread = Thread.currentThread try { - this.success({ - if (cancelled) { - // This action has been cancelled before this thread even started running. - throw new InterruptedException - } - func - }) + if (cancelled) { + // This action has been cancelled before this thread even started running. + this.failure(new SparkException("action cancelled")) + } + this.success(func) } catch { case e: Exception => this.failure(e) } finally { |