From 7a1a524b4ec00dbc493779279e9a4121eca08ba2 Mon Sep 17 00:00:00 2001 From: Alex Zolotko Date: Tue, 25 Feb 2020 11:50:45 +0100 Subject: [PATCH] Treat InterruptedException in CompletionService as task being cancelled --- tasks/src/main/scala/sbt/CompletionService.scala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tasks/src/main/scala/sbt/CompletionService.scala b/tasks/src/main/scala/sbt/CompletionService.scala index 18ed0c481..2338ca885 100644 --- a/tasks/src/main/scala/sbt/CompletionService.scala +++ b/tasks/src/main/scala/sbt/CompletionService.scala @@ -34,8 +34,19 @@ object CompletionService { def take() = completion.take().get() } def submit[T](work: () => T, completion: JCompletionService[T]): () => T = { - val future = try completion.submit { new Callable[T] { def call = work() } } catch { - case _: RejectedExecutionException => throw Incomplete(None, message = Some("cancelled")) + val future = try completion.submit { + new Callable[T] { + def call = + try { + work() + } catch { + case _: InterruptedException => + throw Incomplete(None, message = Some("cancelled")) + } + } + } catch { + case _: RejectedExecutionException => + throw Incomplete(None, message = Some("cancelled")) } () => future.get() }