Skip to content

Commit ebd7d8f

Browse files
authored
chore: try Thread.stop for Java 25 (#597)
Thread.stop will throw unsupported operation on Java 25
1 parent 507257e commit ebd7d8f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sjsonnet/server/src/sjsonnet/SjsonnetServerMain.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.scalasbt.ipcsocket._
88
import sjsonnet.client.{Lock, Locks, ProxyOutputStream, Util => ClientUtil}
99
import sun.misc.{Signal, SignalHandler}
1010

11+
import scala.annotation.nowarn
1112
import scala.util.control.NonFatal
1213

1314
trait SjsonnetServerMain[T] {
@@ -147,6 +148,7 @@ class Server[T](
147148
.getOrElse(throw new Exception("PID already present"))
148149
}
149150

151+
@nowarn("cat=deprecation")
150152
def handleRun(clientSocket: Socket): Unit = {
151153

152154
val currentOutErr = clientSocket.getOutputStream
@@ -208,7 +210,9 @@ class Server[T](
208210
if (!idle) interruptServer()
209211

210212
t.interrupt()
211-
t.stop()
213+
// Thread.stop() is removed in Java 25+; try it for older JVMs but ignore failures
214+
try t.stop()
215+
catch { case NonFatal(_) => }
212216

213217
if (ClientUtil.isWindows) {
214218
// Closing Win32NamedPipeSocket can often take ~5s

0 commit comments

Comments
 (0)