diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/coexistence/UntypedSupervisingTypedSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/coexistence/UntypedSupervisingTypedSpec.scala index 0ae06785f6..6d95f48081 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/coexistence/UntypedSupervisingTypedSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/coexistence/UntypedSupervisingTypedSpec.scala @@ -30,7 +30,6 @@ object ProbedBehavior { probe ! s Behaviors.same } - } } @@ -47,7 +46,6 @@ object UntypedSupervisingTypedSpec { sender() ! TypedSpawnedFromUntypedConext(context.spawn(behav, name)) case SpawnAnonFromUntyped(behav) => sender() ! TypedSpawnedFromUntypedConext(context.spawnAnonymous(behav)) - } } } diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/adapter/ActorRefFactoryAdapter.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/adapter/ActorRefFactoryAdapter.scala index 7cc05c4c99..060ce778fd 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/adapter/ActorRefFactoryAdapter.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/adapter/ActorRefFactoryAdapter.scala @@ -6,11 +6,14 @@ package akka.actor.typed.internal.adapter import akka.actor.typed._ import akka.annotation.InternalApi import akka.ConfigurationException +import akka.util.ErrorMessages /** * INTERNAL API */ @InternalApi private[typed] object ActorRefFactoryAdapter { + + private val remoteDeploymentNotAllowed = "Remote deployment not allowed for typed actors" def spawnAnonymous[T]( context: akka.actor.ActorRefFactory, behavior: Behavior[T], @@ -19,8 +22,8 @@ import akka.ConfigurationException try { ActorRefAdapter(context.actorOf(internal.adapter.PropsAdapter(() => behavior, props, rethrowTypedFailure))) } catch { - case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") => - throw new ConfigurationException("Remote deployment not allowed for typed actors", ex) + case ex: ConfigurationException if ex.getMessage.startsWith(ErrorMessages.RemoteDeploymentConfigErrorPrefix) => + throw new ConfigurationException(remoteDeploymentNotAllowed, ex) } } @@ -36,9 +39,8 @@ import akka.ConfigurationException internal.adapter.PropsAdapter(() => Behavior.validateAsInitial(behavior), props, rethrowTypedFailure), name)) } catch { - case ex: ConfigurationException if ex.getMessage.startsWith("configuration requested remote deployment") => - throw new ConfigurationException("Remote deployment not allowed for typed actors", ex) + case ex: ConfigurationException if ex.getMessage.startsWith(ErrorMessages.RemoteDeploymentConfigErrorPrefix) => + throw new ConfigurationException(remoteDeploymentNotAllowed, ex) } } - } diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Adapter.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Adapter.scala index 13419c4efc..59922975e9 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Adapter.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Adapter.scala @@ -33,7 +33,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorSystem. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawnAnonymous[T](sys: akka.actor.ActorSystem, behavior: Behavior[T]): ActorRef[T] = spawnAnonymous(sys, behavior, EmptyProps) @@ -41,7 +41,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorSystem. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawnAnonymous[T](sys: akka.actor.ActorSystem, behavior: Behavior[T], props: Props): ActorRef[T] = sys.spawnAnonymous(behavior, props) @@ -49,7 +49,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorSystem. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawn[T](sys: akka.actor.ActorSystem, behavior: Behavior[T], name: String): ActorRef[T] = spawn(sys, behavior, name, EmptyProps) @@ -57,7 +57,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorSystem. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawn[T](sys: akka.actor.ActorSystem, behavior: Behavior[T], name: String, props: Props): ActorRef[T] = sys.spawn(behavior, name, props) @@ -65,7 +65,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorContext. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawnAnonymous[T](ctx: akka.actor.ActorContext, behavior: Behavior[T]): ActorRef[T] = spawnAnonymous(ctx, behavior, EmptyProps) @@ -73,7 +73,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorContext. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawnAnonymous[T](ctx: akka.actor.ActorContext, behavior: Behavior[T], props: Props): ActorRef[T] = ctx.spawnAnonymous(behavior, props) @@ -81,7 +81,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorContext. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawn[T](ctx: akka.actor.ActorContext, behavior: Behavior[T], name: String): ActorRef[T] = spawn(ctx, behavior, name, EmptyProps) @@ -89,7 +89,7 @@ object Adapter { /** * Spawn the given behavior as a child of the user actor in an untyped ActorContext. * Typed actors default supervision strategy is to stop. Can be overridden with - * Behaviors.supervise. + * `Behaviors.supervise`. */ def spawn[T](ctx: akka.actor.ActorContext, behavior: Behavior[T], name: String, props: Props): ActorRef[T] = ctx.spawn(behavior, name, props) diff --git a/akka-actor/src/main/scala/akka/util/ErrorMessages.scala b/akka-actor/src/main/scala/akka/util/ErrorMessages.scala new file mode 100644 index 0000000000..447cf68af9 --- /dev/null +++ b/akka-actor/src/main/scala/akka/util/ErrorMessages.scala @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2019 Lightbend Inc. + */ + +package akka.util + +object ErrorMessages { + val RemoteDeploymentConfigErrorPrefix = "configuration requested remote deployment" +} diff --git a/akka-docs/src/main/paradox/typed/coexisting.md b/akka-docs/src/main/paradox/typed/coexisting.md index 5c92412191..c06e357755 100644 --- a/akka-docs/src/main/paradox/typed/coexisting.md +++ b/akka-docs/src/main/paradox/typed/coexisting.md @@ -117,8 +117,8 @@ Java ## Supervision -The default supervision for untyped actors is to restart where as for typed it is to stop. -When combining untyped and and typed actors the default supervision is based on the default behavior of +The default supervision for untyped actors is to restart whereas for typed it is to stop. +When combining untyped and typed actors the default supervision is based on the default behavior of the child i.e. if an untyped actor creates a typed child, its default supervision will be to stop. If a typed actor creates an untyped child, its default supervision will be to restart. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala index 29e8924c64..9053adb1f9 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala @@ -10,19 +10,19 @@ import akka.dispatch.sysmsg._ import akka.event.{ EventStream, Logging, LoggingAdapter } import akka.event.Logging.Error import akka.pattern.pipe -import scala.util.control.NonFatal +import scala.util.control.NonFatal import akka.actor.SystemGuardian.{ RegisterTerminationHook, TerminationHook, TerminationHookDone } + import scala.util.control.Exception.Catcher import scala.concurrent.Future - import akka.ConfigurationException import akka.annotation.InternalApi import akka.dispatch.{ RequiresMessageQueue, UnboundedMessageQueueSemantics } import akka.remote.artery.ArteryTransport import akka.remote.artery.aeron.ArteryAeronUdpTransport import akka.remote.artery.ArterySettings -import akka.util.OptionVal +import akka.util.{ ErrorMessages, OptionVal } import akka.remote.artery.OutboundEnvelope import akka.remote.artery.SystemMessageDelivery.SystemMessageEnvelope import akka.remote.serialization.ActorRefResolveThreadLocalCache @@ -336,7 +336,7 @@ private[akka] class RemoteActorRefProvider( local.actorOf(system, props, supervisor, path, false, deployment.headOption, false, async) } else if (props.deploy.scope == LocalScope) { throw new ConfigurationException( - s"configuration requested remote deployment for local-only Props at [$path]") + s"${ErrorMessages.RemoteDeploymentConfigErrorPrefix} for local-only Props at [$path]") } else try { try {