mirror of https://github.com/sbt/sbt.git
Treat InterruptedException in CompletionService as task being cancelled
This commit is contained in:
parent
dca44d570d
commit
7a1a524b4e
|
|
@ -34,8 +34,19 @@ object CompletionService {
|
||||||
def take() = completion.take().get()
|
def take() = completion.take().get()
|
||||||
}
|
}
|
||||||
def submit[T](work: () => T, completion: JCompletionService[T]): () => T = {
|
def submit[T](work: () => T, completion: JCompletionService[T]): () => T = {
|
||||||
val future = try completion.submit { new Callable[T] { def call = work() } } catch {
|
val future = try completion.submit {
|
||||||
case _: RejectedExecutionException => throw Incomplete(None, message = Some("cancelled"))
|
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()
|
() => future.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue