From 45ed6eabca69d967bc95f219ede501ceb74dd741 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 29 Jan 2020 11:47:18 +0100 Subject: [PATCH] clarify ExecutionContext for whenTerminated operations (#28537) --- .../main/scala/akka/actor/typed/ActorSystem.scala | 10 ++++++++-- .../src/main/scala/akka/actor/ActorSystem.scala | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/ActorSystem.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/ActorSystem.scala index 37609aefd3..004ce176c2 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/ActorSystem.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/ActorSystem.scala @@ -116,9 +116,12 @@ abstract class ActorSystem[-T] extends ActorRef[T] with Extensions with ClassicA def terminate(): Unit /** - * Scala API: Returns a Future which will be completed after the ActorSystem has been terminated - * and termination hooks have been executed. The `ActorSystem` can be stopped with [[ActorSystem.terminate]] + * Scala API: Returns a Future which will be completed after the ActorSystem has been terminated. + * The `ActorSystem` can be stopped with [[ActorSystem.terminate]] * or by stopping the guardian actor. + * + * Be careful to not schedule any operations, such as `onComplete`, on the dispatchers (`ExecutionContext`) + * of this actor system as they will have been shut down before this future completes. */ def whenTerminated: Future[Done] @@ -126,6 +129,9 @@ abstract class ActorSystem[-T] extends ActorRef[T] with Extensions with ClassicA * Java API: Returns a CompletionStage which will be completed after the ActorSystem has been terminated * and termination hooks have been executed. The `ActorSystem` can be stopped with [[ActorSystem.terminate]] * or by stopping the guardian actor. + * + * Be careful to not schedule any operations, such as `thenRunAsync`, on the dispatchers (`Executor`) of this + * actor system as they will have been shut down before this CompletionStage completes. */ def getWhenTerminated: CompletionStage[Done] diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 67da5d7289..37a14f8749 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -684,9 +684,9 @@ abstract class ActorSystem extends ActorRefFactory with ClassicActorSystemProvid * Returns a Future which will be completed after the ActorSystem has been terminated * and termination hooks have been executed. If you registered any callback with * [[ActorSystem#registerOnTermination]], the returned Future from this method will not complete - * until all the registered callbacks are finished. Be careful to not schedule any operations - * on the `dispatcher` of this actor system as it will have been shut down before this - * future completes. + * until all the registered callbacks are finished. Be careful to not schedule any operations, + * such as `onComplete`, on the dispatchers (`ExecutionContext`) of this actor system as they + * will have been shut down before this future completes. */ def whenTerminated: Future[Terminated] @@ -694,9 +694,9 @@ abstract class ActorSystem extends ActorRefFactory with ClassicActorSystemProvid * Returns a CompletionStage which will be completed after the ActorSystem has been terminated * and termination hooks have been executed. If you registered any callback with * [[ActorSystem#registerOnTermination]], the returned CompletionStage from this method will not complete - * until all the registered callbacks are finished. Be careful to not schedule any operations - * on the `dispatcher` of this actor system as it will have been shut down before this - * future completes. + * until all the registered callbacks are finished. Be careful to not schedule any operations, + * such as `thenRunAsync`, on the dispatchers (`Executor`) of this actor system as they + * will have been shut down before this CompletionStage completes. */ def getWhenTerminated: CompletionStage[Terminated]