From ca251eb7c8e09ee0aad88b2ff36e976f7432fb4f Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 20 Sep 2020 21:30:41 -0700 Subject: [PATCH] Catch interrupted exception in shell I noticed in CI that sometimes the client tests exit with an interrupted exception printed. I tracked it down the exception to the call to getExec, which delegateds to CommandExchange.blockUntilNextExec. --- main/src/main/scala/sbt/Main.scala | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index b05af0c78..95ca729a5 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -1041,17 +1041,19 @@ object BuiltinCommands { .extract(s1) .getOpt(Keys.minForcegcInterval) .getOrElse(GCUtil.defaultMinForcegcInterval) - val exec: Exec = getExec(s1, minGCInterval) - val newState = s1 - .copy( - onFailure = Some(Exec(Shell, None)), - remainingCommands = exec +: Exec(Shell, None) +: s1.remainingCommands - ) - .setInteractive(true) - val res = - if (exec.commandLine.trim.isEmpty) newState - else newState.clearGlobalLog - res + try { + val exec: Exec = getExec(s1, minGCInterval) + val newState = s1 + .copy( + onFailure = Some(Exec(Shell, None)), + remainingCommands = exec +: Exec(Shell, None) +: s1.remainingCommands + ) + .setInteractive(true) + val res = + if (exec.commandLine.trim.isEmpty) newState + else newState.clearGlobalLog + res + } catch { case _: InterruptedException => s1.exit(true) } } }