Skip to content

Commit

Permalink
fix: proper path when promise actor terminated quickly (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roiocam authored Feb 28, 2024
1 parent d884540 commit 2fdf7c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions actor-tests/src/test/scala/org/apache/pekko/pattern/AskSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,29 @@ class AskSpec extends PekkoSpec("""
val (promiseActorRefForSelection, "ask") = p.expectMsgType[(ActorRef, String)]: @unchecked
promiseActorRefForSelection.path.name should startWith("_user_myName")
}

"proper path when promise actor terminated" in {
implicit val timeout: Timeout = Timeout(300 millis)
val p = TestProbe()

val act = system.actorOf(Props(new Actor {
def receive = {
case _ =>
val senderRef: ActorRef = sender()
senderRef ! "complete"
p.ref ! senderRef
}
}), "pathPrefix")

val f = (act ? "ask").mapTo[String]
val promiseActorRef = p.expectMsgType[ActorRef]: @unchecked

// verify ask complete
val completed = f.futureValue
completed should ===("complete")
// verify path was proper
promiseActorRef.path.toString should include("pathPrefix")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private[pekko] final class PromiseActorRef(
case StoppedWithPath(p) => p
case Stopped =>
// even if we are already stopped we still need to produce a proper path
updateState(Stopped, StoppedWithPath(provider.tempPath()))
updateState(Stopped, StoppedWithPath(provider.tempPath(refPathPrefix)))
path
case Registering => path // spin until registration is completed
case unexpected => throw new IllegalStateException(s"Unexpected state: $unexpected")
Expand Down

0 comments on commit 2fdf7c9

Please sign in to comment.