Merge pull request #5945 from eatkins/boot-system-in-fix

Fix sbt hangs with invalid build.sbt and --batch
This commit is contained in:
eugene yokota 2020-10-06 16:20:54 -04:00 committed by GitHub
commit 715bccacd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -179,6 +179,7 @@ trait Terminal extends AutoCloseable {
}
object Terminal {
val NO_BOOT_CLIENTS_CONNECTED: Int = -2
// Disable noisy jline log spam
if (System.getProperty("sbt.jline.verbose", "false") != "true")
jline.internal.Log.setOutput(new PrintStream(_ => {}, false))
@ -619,6 +620,11 @@ object Terminal {
if (running.get) {
inputStream.read match {
case -1 =>
case `NO_BOOT_CLIENTS_CONNECTED` =>
if (System.console == null) {
result.put(-1)
running.set(false)
}
case i =>
result.put(i)
running.set(false)

View File

@ -216,6 +216,7 @@ public class BootServerSocket implements AutoCloseable {
new InputStream() {
@Override
public int read() {
if (clientSockets.isEmpty()) return Terminal.NO_BOOT_CLIENTS_CONNECTED();
try {
synchronized (needInput) {
needInput.set(true);