mirror of https://github.com/sbt/sbt.git
commit
5f127c6339
|
|
@ -14,7 +14,7 @@ import scala.util.control.NonFatal
|
|||
|
||||
private[sbt] object ShutdownHooks extends AutoCloseable {
|
||||
private[this] val idGenerator = new AtomicInteger(0)
|
||||
private[this] val hooks = new ConcurrentHashMap[Int, () => Any]
|
||||
private[this] val hooks = new ConcurrentHashMap[Int, () => Unit]
|
||||
private[this] val ranHooks = new AtomicBoolean(false)
|
||||
private[this] val thread = new Thread("shutdown-hooks-run-all") {
|
||||
override def run(): Unit = runAll()
|
||||
|
|
@ -26,8 +26,10 @@ private[sbt] object ShutdownHooks extends AutoCloseable {
|
|||
hooks.put(
|
||||
id,
|
||||
() =>
|
||||
try task()
|
||||
catch {
|
||||
try {
|
||||
task()
|
||||
()
|
||||
} catch {
|
||||
case NonFatal(e) =>
|
||||
System.err.println(s"Caught exception running shutdown hook: $e")
|
||||
e.printStackTrace(System.err)
|
||||
|
|
@ -36,7 +38,7 @@ private[sbt] object ShutdownHooks extends AutoCloseable {
|
|||
() => Option(hooks.remove(id)).foreach(_.apply())
|
||||
}
|
||||
private def runAll(): Unit = if (ranHooks.compareAndSet(false, true)) {
|
||||
hooks.forEachValue(Runtime.getRuntime.availableProcessors, _.apply())
|
||||
hooks.forEachValue(runtime.availableProcessors.toLong, _.apply())
|
||||
}
|
||||
override def close(): Unit = {
|
||||
runtime.removeShutdownHook(thread)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import sbt.BasicCommandStrings.ContinuousExecutePrefix
|
|||
import sbt._
|
||||
import sbt.internal.LabeledFunctions._
|
||||
import sbt.internal.nio.FileEvent
|
||||
import sbt.internal.util.Util
|
||||
import sbt.internal.util.complete.Parser
|
||||
import sbt.internal.util.complete.Parser._
|
||||
import sbt.nio.file.FileAttributes
|
||||
|
|
|
|||
Loading…
Reference in New Issue