Merge pull request #8005 from dwickern/fix-npe

Fix race condition in NetworkChannel
This commit is contained in:
eugene yokota 2025-01-11 22:26:21 -05:00 committed by GitHub
commit d99163b945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -163,7 +163,7 @@ final class NetworkChannel(
}
}
val thread = new Thread(s"sbt-networkchannel-${connection.getPort}") {
private[this] val thread = new Thread(s"sbt-networkchannel-${connection.getPort}") {
private val ct = "Content-Type: "
private val x1 = "application/sbt-x1"
override def run(): Unit = {
@ -241,7 +241,6 @@ final class NetworkChannel(
}
}
}
thread.start()
private[sbt] def isLanguageServerProtocol: Boolean = true
@ -365,7 +364,6 @@ final class NetworkChannel(
impl()
}, s"sbt-$name-write-thread")
writeThread.setDaemon(true)
writeThread.start()
def publishBytes(event: Array[Byte], delimit: Boolean): Unit =
try pendingWrites.put(event -> delimit)
@ -914,6 +912,9 @@ final class NetworkChannel(
}
}
private[sbt] def isAttached: Boolean = attached.get
thread.start()
writeThread.start()
}
object NetworkChannel {