Properly handle interrupted exception in FutureAction.
Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/09f76092 Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/09f76092 Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/09f76092 Branch: refs/heads/master Commit: 09f7609254a8b70a551e7403bc5378434318b3f4 Parents: 42fb1df Author: Reynold Xin <r...@apache.org> Authored: Fri Oct 11 11:20:15 2013 -0700 Committer: Reynold Xin <r...@apache.org> Committed: Fri Oct 11 11:20:15 2013 -0700 ---------------------------------------------------------------------- core/src/main/scala/org/apache/spark/FutureAction.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/09f76092/core/src/main/scala/org/apache/spark/FutureAction.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/spark/FutureAction.scala b/core/src/main/scala/org/apache/spark/FutureAction.scala index 64e354e..9f41912 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 {