[2.x] fix: Catch timeout on sbtn exit (#9239)

**Problem**
sbtn tries to wait on a thread on exit, and times out.

**Solution**
Shorten the timeout and catch it.
This commit is contained in:
eugene yokota 2026-05-17 05:44:40 -04:00 committed by GitHub
parent 46f0b89642
commit df038e78a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -135,13 +135,14 @@ private[sbt] class ServerSessionImpl(
*/ */
override def close(): Unit = if (closed.compareAndSet(false, true)) { override def close(): Unit = if (closed.compareAndSet(false, true)) {
running.set(false) running.set(false)
try { try
out.close() out.close()
socket.close() socket.close()
} catch { case _: IOException => } catch case _: IOException => ()
onClose() onClose()
if (Thread.currentThread() != readThread) if Thread.currentThread() != readThread then
readThread.joinFor(ServerSessionImpl.ReadThreadDestroyTimeout) try readThread.joinFor(ServerSessionImpl.ReadThreadDestroyTimeout)
catch case _: TimeoutException => ()
} }
override def nextId(): String = UUID.randomUUID.toString override def nextId(): String = UUID.randomUUID.toString
@ -351,7 +352,7 @@ private[sbt] class ServerSessionImpl(
private[sbt] object ServerSessionImpl { private[sbt] object ServerSessionImpl {
val ReadIoTimeout: Int = 5000 // ms val ReadIoTimeout: Int = 5000 // ms
val ReadThreadDestroyTimeout: FiniteDuration = 5.seconds val ReadThreadDestroyTimeout: FiniteDuration = 1.seconds
val ResponseTimeout: FiniteDuration = 1.minutes val ResponseTimeout: FiniteDuration = 1.minutes
val GracefulShutdownTimeout: FiniteDuration = 5.seconds val GracefulShutdownTimeout: FiniteDuration = 5.seconds
val DestroyTimeout: FiniteDuration = 10.seconds val DestroyTimeout: FiniteDuration = 10.seconds