From 39af464dfdd2167f29939484842797d57343cb71 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 17 Nov 2020 20:04:27 -0800 Subject: [PATCH] Fix shutdown for thin client shell When a user enters shutdown in the thin client console, it only exits the thin client, it does not actually shutdown sbt. Running `sbtn shutdown` did work to shutdown the server, however. It turned out that this was because there was special handling for shutdown when processed through jline. We would enqueue the shutdown command and also close the client connection. Closing the client connection though removed all of the enqueued commands for the client, which included the shutdown command. To fix this, we just make sure that we don't remove the shutdown command when clearing the client commands. --- main/src/main/scala/sbt/internal/CommandExchange.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/internal/CommandExchange.scala b/main/src/main/scala/sbt/internal/CommandExchange.scala index d2747a302..29f34f7da 100644 --- a/main/src/main/scala/sbt/internal/CommandExchange.scala +++ b/main/src/main/scala/sbt/internal/CommandExchange.scala @@ -160,7 +160,9 @@ private[sbt] final class CommandExchange { channelBufferLock.synchronized { Util.ignoreResult(channelBuffer -= c) } - commandQueue.removeIf(_.source.map(_.channelName) == Some(c.name)) + commandQueue.removeIf { e => + e.source.map(_.channelName) == Some(c.name) && e.commandLine != Shutdown + } currentExec.filter(_.source.map(_.channelName) == Some(c.name)).foreach { e => Util.ignoreResult(NetworkChannel.cancel(e.execId, e.execId.getOrElse("0"))) }