mirror of https://github.com/sbt/sbt.git
Catch RejectedExecutionException in CompletionService.submit
This commit is contained in:
parent
d48aa310e6
commit
b78a0f667b
|
|
@ -17,7 +17,8 @@ import java.util.concurrent.{
|
|||
CompletionService => JCompletionService,
|
||||
Executor,
|
||||
Executors,
|
||||
ExecutorCompletionService
|
||||
ExecutorCompletionService,
|
||||
RejectedExecutionException,
|
||||
}
|
||||
|
||||
object CompletionService {
|
||||
|
|
@ -33,7 +34,9 @@ object CompletionService {
|
|||
def take() = completion.take().get()
|
||||
}
|
||||
def submit[T](work: () => T, completion: JCompletionService[T]): () => T = {
|
||||
val future = completion.submit { new Callable[T] { def call = work() } }
|
||||
val future = try completion.submit { new Callable[T] { def call = work() } } catch {
|
||||
case _: RejectedExecutionException => throw Incomplete(None, message = Some("cancelled"))
|
||||
}
|
||||
() =>
|
||||
future.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
package sbt
|
||||
|
||||
import java.util.concurrent.RejectedExecutionException
|
||||
|
||||
import sbt.internal.util.ErrorHandling.wideConvert
|
||||
import sbt.internal.util.{ DelegatingPMap, IDSet, PMap, RMap, ~> }
|
||||
import sbt.internal.util.Types._
|
||||
|
|
@ -80,19 +78,16 @@ private[sbt] final class Execute[A[_] <: AnyRef](
|
|||
def run[T](root: A[T])(implicit strategy: Strategy): Result[T] =
|
||||
try { runKeep(root)(strategy)(root) } catch { case i: Incomplete => Inc(i) }
|
||||
|
||||
def runKeep[T](root: A[T])(implicit strategy: Strategy): RMap[A, Result] =
|
||||
try {
|
||||
assert(state.isEmpty, "Execute already running/ran.")
|
||||
def runKeep[T](root: A[T])(implicit strategy: Strategy): RMap[A, Result] = {
|
||||
assert(state.isEmpty, "Execute already running/ran.")
|
||||
|
||||
addNew(root)
|
||||
processAll()
|
||||
assert(results contains root, "No result for root node.")
|
||||
val finalResults = triggers.onComplete(results)
|
||||
progressState = progress.allCompleted(progressState, finalResults)
|
||||
finalResults
|
||||
} catch {
|
||||
case _: RejectedExecutionException => throw Incomplete(None, message = Some("cancelled"))
|
||||
}
|
||||
addNew(root)
|
||||
processAll()
|
||||
assert(results contains root, "No result for root node.")
|
||||
val finalResults = triggers.onComplete(results)
|
||||
progressState = progress.allCompleted(progressState, finalResults)
|
||||
finalResults
|
||||
}
|
||||
|
||||
def processAll()(implicit strategy: Strategy): Unit = {
|
||||
@tailrec def next(): Unit = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue