remove deprecated ActorSystem termination methods, #21423

* those were deprecated by #15757 before 2.4.0
This commit is contained in:
Patrik Nordwall 2017-01-19 14:10:55 +01:00
parent 2a9fa234a1
commit 0f8f47878b
6 changed files with 17 additions and 50 deletions

View file

@ -197,30 +197,26 @@ class ActorSystemSpec extends AkkaSpec(ActorSystemSpec.config) with ImplicitSend
import system.dispatcher
system2.scheduler.scheduleOnce(200.millis.dilated) { system2.terminate() }
system2.awaitTermination(5 seconds)
Await.ready(system2.whenTerminated, 5 seconds)
callbackWasRun should ===(true)
}
"return isTerminated status correctly" in {
val system = ActorSystem().asInstanceOf[ActorSystemImpl]
system.isTerminated should ===(false)
val wt = system.whenTerminated
wt.isCompleted should ===(false)
val f = system.terminate()
val terminated = Await.result(wt, 10 seconds)
system.whenTerminated.isCompleted should ===(true)
terminated.actor should ===(system.provider.rootGuardian)
terminated.addressTerminated should ===(true)
terminated.existenceConfirmed should ===(true)
terminated should be theSameInstanceAs Await.result(f, 10 seconds)
system.awaitTermination(10 seconds)
system.isTerminated should ===(true)
}
"throw RejectedExecutionException when shutdown" in {
val system2 = ActorSystem("AwaitTermination", AkkaSpec.testConf)
Await.ready(system2.terminate(), 10 seconds)
system2.awaitTermination(10 seconds)
intercept[RejectedExecutionException] {
system2.registerOnTermination { println("IF YOU SEE THIS THEN THERE'S A BUG HERE") }

View file

@ -44,7 +44,7 @@ class AddressTerminatedTopicBenchSpec extends AkkaSpec("akka.loglevel=INFO") {
shutdown(sys, 10.seconds, verifySystemShutdown = true)
log.info("Stopping {} actors took {} ms", num, (System.nanoTime() - t2).nanos.toMillis)
} finally {
if (!sys.isTerminated) shutdown(sys)
shutdown(sys)
}
}

View file

@ -523,42 +523,6 @@ abstract class ActorSystem extends ActorRefFactory {
*/
def registerOnTermination(code: Runnable): Unit
/**
* Block current thread until the system has been shutdown, or the specified
* timeout has elapsed. This will block until after all on termination
* callbacks have been run.
*
* Throws TimeoutException in case of timeout.
*/
@deprecated("Use Await.result(whenTerminated, timeout) instead", "2.4")
def awaitTermination(timeout: Duration): Unit
/**
* Block current thread until the system has been shutdown. This will
* block until after all on termination callbacks have been run.
*/
@deprecated("Use Await.result(whenTerminated, Duration.Inf) instead", "2.4")
def awaitTermination(): Unit
/**
* Stop this actor system. This will stop the guardian actor, which in turn
* will recursively stop all its child actors, then the system guardian
* (below which the logging actors reside) and the execute all registered
* termination handlers (see [[ActorSystem#registerOnTermination]]).
*/
@deprecated("Use the terminate() method instead", "2.4")
def shutdown(): Unit
/**
* Query the termination status: if it returns true, all callbacks have run
* and the ActorSystem has been fully stopped, i.e.
* `awaitTermination(0 seconds)` would return normally. If this method
* returns `false`, the status is actually unknown, since it might have
* changed since you queried it.
*/
@deprecated("Use the whenTerminated method instead.", "2.4")
def isTerminated: Boolean
/**
* Terminates this actor system. This will stop the guardian actor, which in turn
* will recursively stop all its child actors, then the system guardian
@ -820,11 +784,6 @@ private[akka] class ActorSystemImpl(
def start(): this.type = _start
def registerOnTermination[T](code: T) { registerOnTermination(new Runnable { def run = code }) }
def registerOnTermination(code: Runnable) { terminationCallbacks.add(code) }
override def awaitTermination(timeout: Duration) { Await.ready(whenTerminated, timeout) }
override def awaitTermination() = awaitTermination(Duration.Inf)
override def isTerminated = whenTerminated.isCompleted
override def shutdown(): Unit = terminate()
override def terminate(): Future[Terminated] = {
if (!settings.LogDeadLettersDuringShutdown) logDeadLetterListener foreach stop

View file

@ -13,6 +13,7 @@ import akka.event.Logging
import akka.testkit.TestEvent
import akka.testkit.EventFilter
import org.testng.annotations.BeforeClass
import scala.concurrent.Await
trait ActorSystemLifecycle {
@ -31,8 +32,7 @@ trait ActorSystemLifecycle {
@AfterClass
def shutdownActorSystem(): Unit = {
try {
system.terminate()
system.awaitTermination(shutdownTimeout)
Await.ready(system.terminate(), shutdownTimeout)
} catch {
case _: TimeoutException
val msg = "Failed to stop [%s] within [%s] \n%s".format(system.name, shutdownTimeout,

View file

@ -413,7 +413,9 @@ class TcpSpec extends StreamSpec("akka.stream.materializer.subscription-timeout.
result.failed.futureValue shouldBe a[StreamTcpException]
binding.map(_.unbind()).recover { case NonFatal(_) () } foreach (_ system2.shutdown())
binding.map(_.unbind()).recover { case NonFatal(_) () }.foreach { _
shutdown(system2)
}
}
}

View file

@ -238,6 +238,16 @@ object MiMa extends AutoPlugin {
// object akka.stream.stage.StatefulStage#Finish does not have a correspondent in current version
ProblemFilters.exclude[MissingClassProblem]("akka.stream.stage.StatefulStage$Finish$"),
// #21423 remove deprecated ActorSystem termination methods (in 2.5.x)
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystemImpl.shutdown"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystemImpl.isTerminated"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystemImpl.awaitTermination"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystemImpl.awaitTermination"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystem.shutdown"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystem.isTerminated"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystem.awaitTermination"),
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.ActorSystem.awaitTermination"),
// #21423 removal of deprecated `PersistentView` (in 2.5.x)
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.Update"),
ProblemFilters.exclude[MissingClassProblem]("akka.persistence.Update$"),