Disable console ui for client launched server

If the sbt server is launched by the remote client, it should not have a
console ui thread because there is no way to even feed input to it once
the server has launched. Having the ui thread can cause the server to
exit unexpectedly if an EOF is read from the console input stream.
This commit is contained in:
Ethan Atkins 2020-11-19 08:23:15 -08:00
parent f3b3148c58
commit 7a8a5e5dac
1 changed files with 3 additions and 6 deletions

View File

@ -51,7 +51,6 @@ private[sbt] final class CommandExchange {
private var server: Option[ServerInstance] = None
private val firstInstance: AtomicBoolean = new AtomicBoolean(true)
private val monitoringActiveJson: AtomicBoolean = new AtomicBoolean(false)
private var consoleChannel: Option[ConsoleChannel] = None
private val commandQueue: LinkedBlockingQueue[Exec] = new LinkedBlockingQueue[Exec]
private val channelBuffer: ListBuffer[CommandChannel] = new ListBuffer()
private val channelBufferLock = new AnyRef {}
@ -60,6 +59,7 @@ private[sbt] final class CommandExchange {
private[this] val lastState = new AtomicReference[State]
private[this] val currentExecRef = new AtomicReference[Exec]
private[sbt] def hasServer = server.isDefined
addConsoleChannel()
def channels: List[CommandChannel] = channelBuffer.toList
@ -141,11 +141,9 @@ private[sbt] final class CommandExchange {
}
private def addConsoleChannel(): Unit =
if (consoleChannel.isEmpty) {
if (!Terminal.startedByRemoteClient) {
val name = ConsoleChannel.defaultName
val console0 = new ConsoleChannel(name, mkAskUser(name))
consoleChannel = Some(console0)
subscribe(console0)
subscribe(new ConsoleChannel(name, mkAskUser(name)))
}
def run(s: State): State = run(s, s.get(autoStartServer).getOrElse(true))
def run(s: State, autoStart: Boolean): State = {
@ -402,7 +400,6 @@ private[sbt] final class CommandExchange {
.withChannelName(currentExec.flatMap(_.source.map(_.channelName)))
case _ => pe
}
if (channels.isEmpty) addConsoleChannel()
channels.foreach(c => ProgressState.updateProgressState(newPE, c.terminal))
}