mirror of https://github.com/sbt/sbt.git
Merge pull request #1 from dwijnand/topic/quietly-cancel
Catch RejectedExecutionException into an Incomplete
This commit is contained in:
commit
015c3103f4
|
|
@ -11,7 +11,6 @@ import sbt.internal.{ Load, BuildStructure, TaskTimings, TaskName, GCUtil }
|
|||
import sbt.internal.util.{ Attributed, ErrorHandling, HList, RMap, Signals, Types }
|
||||
import sbt.util.{ Logger, Show }
|
||||
import sbt.librarymanagement.{ Resolver, UpdateReport }
|
||||
import java.util.concurrent.RejectedExecutionException
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
import java.io.File
|
||||
|
|
@ -388,11 +387,7 @@ object EvaluateTask {
|
|||
val results = x.runKeep(root)(service)
|
||||
storeValuesForPrevious(results, state, streams)
|
||||
applyResults(results, state, root)
|
||||
} catch {
|
||||
case _: RejectedExecutionException =>
|
||||
(state, Inc(Incomplete(None, message = Some("cancelled"))))
|
||||
case inc: Incomplete => (state, Inc(inc))
|
||||
} finally shutdown()
|
||||
} catch { case inc: Incomplete => (state, Inc(inc)) } finally shutdown()
|
||||
val replaced = transformInc(result)
|
||||
logIncResult(replaced, state, streams)
|
||||
(newState, replaced)
|
||||
|
|
|
|||
|
|
@ -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._
|
||||
|
|
@ -78,12 +76,8 @@ private[sbt] final class Execute[A[_] <: AnyRef](
|
|||
"State: " + state.toString + "\n\nResults: " + results + "\n\nCalls: " + callers + "\n\n"
|
||||
|
||||
def run[T](root: A[T])(implicit strategy: Strategy): Result[T] =
|
||||
try {
|
||||
runKeep(root)(strategy)(root)
|
||||
} catch {
|
||||
case i: Incomplete => Inc(i)
|
||||
case _: RejectedExecutionException => Inc(Incomplete(None, message = Some("cancelled")))
|
||||
}
|
||||
try { runKeep(root)(strategy)(root) } catch { case i: Incomplete => Inc(i) }
|
||||
|
||||
def runKeep[T](root: A[T])(implicit strategy: Strategy): RMap[A, Result] = {
|
||||
assert(state.isEmpty, "Execute already running/ran.")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue