diff --git a/core/src/main/scala/org/apache/spark/FutureAction.scala b/core/src/main/scala/org/apache/spark/FutureAction.scala index 64e354e2e3eac8d747fd65310efcb65986989780..9f41912d6c4b857894b9f87a3aed99ed55437740 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 {