Merge pull request #6213 from eatkins/rejected-execution

Catch RejectedExecutionException in MainLoop
This commit is contained in:
eugene yokota 2020-12-18 20:28:26 -05:00 committed by GitHub
commit 8a6c10327b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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
}

View File

@ -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()
}
}