mirror of https://github.com/sbt/sbt.git
Add timeouts for completion prompts
CI hung in the server test that checks completions because I broke reading from the System.in. It occurred to me that we probably shouldn't prompt indefinitely when the user is running tab completions anyway so I set a timeout of 5 seconds for the user to respond to input. If they decline to start a server within the timeout, we will just exit. If they decline to run compilation within the timeout we just skip the compilation step (so test or main class names will not be provided for completions).
This commit is contained in:
parent
bb8b9a1c99
commit
0427e5f9c5
|
|
@ -151,7 +151,7 @@ class NetworkClient(
|
|||
}
|
||||
}
|
||||
|
||||
private[this] val stdinBytes = new LinkedBlockingQueue[Int]
|
||||
private[this] val stdinBytes = new LinkedBlockingQueue[Integer]
|
||||
private[this] val inLock = new Object
|
||||
private[this] val inputThread = new AtomicReference[RawInputThread]
|
||||
private[this] val exitClean = new AtomicBoolean(true)
|
||||
|
|
@ -174,8 +174,9 @@ class NetworkClient(
|
|||
else if (noTab) waitForServer(portfile, log = true, startServer = true)
|
||||
else {
|
||||
startInputThread()
|
||||
stdinBytes.take match {
|
||||
case 9 =>
|
||||
stdinBytes.poll(5, TimeUnit.SECONDS) match {
|
||||
case null => System.exit(0)
|
||||
case i if i == 9 =>
|
||||
errorStream.println("\nStarting server...")
|
||||
waitForServer(portfile, !promptCompleteUsers, startServer = true)
|
||||
case _ => System.exit(0)
|
||||
|
|
@ -811,9 +812,10 @@ class NetworkClient(
|
|||
else {
|
||||
errorStream.print(s"\nNo cached $label names found. Press '<tab>' to compile: ")
|
||||
startInputThread()
|
||||
stdinBytes.take match {
|
||||
case 9 => updateCompletions()
|
||||
case _ => Nil
|
||||
stdinBytes.poll(5, TimeUnit.SECONDS) match {
|
||||
case null => Nil
|
||||
case i if i == 9 => updateCompletions()
|
||||
case _ => Nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue