Properly handle interrupted exception in FutureAction.

This commit is contained in:
Reynold Xin 2013-10-11 11:20:15 -07:00
parent 42fb1df694
commit 09f7609254

View file

@ -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 {