Merge pull request #4205 from sbt/1.1.x

Merge 1.1.x
This commit is contained in:
eugene yokota 2018-06-15 15:33:02 -04:00 committed by GitHub
commit f3618c74b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -105,13 +105,30 @@ object StandardMain {
import scalacache.caffeine._
private[sbt] lazy val cache: Cache[Any] = CaffeineCache[Any]
private[sbt] val shutdownHook = new Thread(new Runnable {
def run(): Unit = {
exchange.shutdown
}
})
def runManaged(s: State): xsbti.MainResult = {
val previous = TrapExit.installManager()
try {
try {
val hooked = try {
Runtime.getRuntime.addShutdownHook(shutdownHook)
true
} catch {
case _: IllegalArgumentException => false
}
try {
MainLoop.runLogged(s)
} finally exchange.shutdown
} finally {
exchange.shutdown
if (hooked) {
Runtime.getRuntime.removeShutdownHook(shutdownHook)
}
}
} finally DefaultBackgroundJobService.backgroundJobService.shutdown()
} finally TrapExit.uninstallManager(previous)
}