[2.x] fix: Error "Exception in thread "sbt-socket-server" java.lang.NullPointerException" on exit (#8448)

Fixes #8538

The code was calling e.getMessage.contains() without checking if getMessage()
returns null. Changed to use Option(e.getMessage).exists() to safely handle
null values.
This commit is contained in:
aka James4u 2026-01-15 08:06:51 -08:00 committed by GitHub
parent 7368252678
commit dce915e794
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -114,8 +114,8 @@ private[sbt] object Server {
val socket = serverSocket.accept()
onIncomingSocket(socket, self)
} catch {
case e: IOException if e.getMessage.contains("connect") =>
case _: SocketTimeoutException => // its ok
case e: IOException if Option(e.getMessage).exists(_.contains("connect")) =>
case _: SocketTimeoutException => // its ok
case _: SocketException if !running.get => // the server is shutting down
}
}