Remove shutdown hook on shutting down (#23866)

When shutting down, we compliment the addition of a shutdown hook during startup with its removal. Doing so further ensures that no class loader is retained when unloading Akka in an OSGi style scenario.
This commit is contained in:
Christopher Hunt 2017-10-31 01:09:38 +11:00 committed by Arnout Engelen
parent 83a97256cc
commit aa2ab4b6e2

View file

@ -865,6 +865,7 @@ private[remote] class ArteryTransport(_system: ExtendedActorSystem, _provider: R
override def shutdown(): Future[Done] = { override def shutdown(): Future[Done] = {
if (hasBeenShutdown.compareAndSet(false, true)) { if (hasBeenShutdown.compareAndSet(false, true)) {
log.debug("Shutting down [{}]", localAddress) log.debug("Shutting down [{}]", localAddress)
Runtime.getRuntime.removeShutdownHook(shutdownHook)
val allAssociations = associationRegistry.allAssociations val allAssociations = associationRegistry.allAssociations
val flushing: Future[Done] = val flushing: Future[Done] =
if (allAssociations.isEmpty) Future.successful(Done) if (allAssociations.isEmpty) Future.successful(Done)