diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala index e8440efe31..9752154e86 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala @@ -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") } diff --git a/akka-actor-tests/src/test/scala/akka/event/AddressTerminatedTopicBenchSpec.scala b/akka-actor-tests/src/test/scala/akka/event/AddressTerminatedTopicBenchSpec.scala index 486a43c1a7..4c713af608 100644 --- a/akka-actor-tests/src/test/scala/akka/event/AddressTerminatedTopicBenchSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/AddressTerminatedTopicBenchSpec.scala @@ -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) } } diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 211ab221e6..d46825af38 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -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 diff --git a/akka-stream-tests-tck/src/test/scala/akka/stream/tck/ActorSystemLifecycle.scala b/akka-stream-tests-tck/src/test/scala/akka/stream/tck/ActorSystemLifecycle.scala index c97bbcb056..bd55d72a15 100644 --- a/akka-stream-tests-tck/src/test/scala/akka/stream/tck/ActorSystemLifecycle.scala +++ b/akka-stream-tests-tck/src/test/scala/akka/stream/tck/ActorSystemLifecycle.scala @@ -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, diff --git a/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala index dc84fb9824..3b71b08840 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/io/TcpSpec.scala @@ -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) + } } } diff --git a/project/MiMa.scala b/project/MiMa.scala index 3cf1ab73d6..a177f4b46c 100644 --- a/project/MiMa.scala +++ b/project/MiMa.scala @@ -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$"),