Fail fast on empty string persistenceId in PersistentActor (#24239)
This commit is contained in:
parent
5a66976683
commit
1dffa344c4
2 changed files with 15 additions and 0 deletions
|
|
@ -194,6 +194,7 @@ private[persistence] trait Eventsourced extends Snapshotter with PersistenceStas
|
|||
/** INTERNAL API. */
|
||||
override protected[akka] def aroundPreStart(): Unit = {
|
||||
require(persistenceId ne null, s"persistenceId is [null] for PersistentActor [${self.path}]")
|
||||
require(persistenceId.trim.nonEmpty, s"persistenceId cannot be empty for PersistentActor [${self.path}]")
|
||||
|
||||
// Fail fast on missing plugins.
|
||||
val j = journal; val s = snapshotStore
|
||||
|
|
|
|||
|
|
@ -692,6 +692,20 @@ abstract class PersistentActorSpec(config: Config) extends PersistenceSpec(confi
|
|||
}
|
||||
}
|
||||
}
|
||||
"fail fast if persistenceId is an empty string" in {
|
||||
import akka.testkit.filterEvents
|
||||
filterEvents(EventFilter[ActorInitializationException]()) {
|
||||
EventFilter.error(message = "persistenceId cannot be empty for PersistentActor") intercept {
|
||||
val ref = system.actorOf(Props(new NamedPersistentActor(" ") {
|
||||
override def receiveRecover: Receive = Actor.emptyBehavior
|
||||
|
||||
override def receiveCommand: Receive = Actor.emptyBehavior
|
||||
}))
|
||||
watch(ref)
|
||||
expectTerminated(ref)
|
||||
}
|
||||
}
|
||||
}
|
||||
"recover from persisted events" in {
|
||||
val persistentActor = namedPersistentActor[Behavior1PersistentActor]
|
||||
persistentActor ! GetState
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue