From 09f7609254a8b70a551e7403bc5378434318b3f4 Mon Sep 17 00:00:00 2001
From: Reynold Xin <rxin@apache.org>
Date: Fri, 11 Oct 2013 11:20:15 -0700
Subject: [PATCH] Properly handle interrupted exception in FutureAction.

---
 .../main/scala/org/apache/spark/FutureAction.scala   | 12 +++++-------
 1 file 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 {
-- 
GitLab