* Review follow ups for PR #26653 * Internal marker for error messages
This commit is contained in:
commit
6207484c0e
6 changed files with 33 additions and 21 deletions
|
|
@ -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))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
12
akka-actor/src/main/scala/akka/util/ErrorMessages.scala
Normal file
12
akka-actor/src/main/scala/akka/util/ErrorMessages.scala
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.util
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
private[akka] object ErrorMessages {
|
||||
val RemoteDeploymentConfigErrorPrefix = "configuration requested remote deployment"
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue