mirror of
https://github.com/sbt/sbt.git
synced 2026-10-06 10:03:56 +02:00
Catch RejectedExecutionException in MainLoop
sbt 1.4.x was printing a very verbose and annoying RejectedExectionException when the user cancelled tasks with ctrl+c. Fixes #6192
This commit is contained in:
committed by
Eugene Yokota
parent
3a658dda2a
commit
63c9a1ae93
@@ -8,6 +8,7 @@
|
||||
package sbt
|
||||
|
||||
import java.io.PrintWriter
|
||||
import java.util.concurrent.RejectedExecutionException
|
||||
import java.util.Properties
|
||||
|
||||
import sbt.BasicCommandStrings.{ StashOnFailure, networkExecPrefix }
|
||||
@@ -240,6 +241,13 @@ object MainLoop {
|
||||
FastTrackCommands
|
||||
.evaluate(termState, exec.commandLine)
|
||||
.getOrElse(Command.process(exec.commandLine, termState))
|
||||
} catch {
|
||||
case _: RejectedExecutionException =>
|
||||
// No stack trace since this is just to notify the user which command they cancelled
|
||||
object Cancelled extends Throwable(exec.commandLine, null, true, false) {
|
||||
override def toString: String = s"Cancelled: ${exec.commandLine}"
|
||||
}
|
||||
throw Cancelled
|
||||
} finally {
|
||||
// Flush the terminal output after command evaluation to ensure that all output
|
||||
// is displayed in the thin client before we report the command status. Also
|
||||
@@ -328,5 +336,4 @@ object MainLoop {
|
||||
if (prevState.onFailure.isDefined && state.onFailure.isEmpty &&
|
||||
state.currentCommand.fold(true)(_ != StashOnFailure)) ExitCode(ErrorCodes.UnknownError)
|
||||
else ExitCode.Success
|
||||
|
||||
}
|
||||
|
||||
@@ -305,7 +305,9 @@ object ConcurrentRestrictions {
|
||||
|
||||
def take(): R = {
|
||||
if (closed.get)
|
||||
throw new IllegalStateException("Tried to get values for a closed completion service")
|
||||
throw new RejectedExecutionException(
|
||||
"Tried to get values for a closed completion service"
|
||||
)
|
||||
jservice.take().get()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user