diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorSelectionSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorSelectionSpec.scala index f45b7b5e4f..8346778ac8 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorSelectionSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorSelectionSpec.scala @@ -144,7 +144,6 @@ class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTim "select system-generated actors" in { identify("/user") should be(Some(user)) - identify("/deadLetters") should be(Some(system.deadLetters)) identify("/system") should be(Some(syst)) identify(syst.path) should be(Some(syst)) identify(syst.path.toStringWithoutAddress) should be(Some(syst)) @@ -155,19 +154,21 @@ class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTim identify(root.path) should be(Some(root)) identify(root.path.toStringWithoutAddress) should be(Some(root)) identify("user") should be(Some(user)) - identify("deadLetters") should be(Some(system.deadLetters)) identify("system") should be(Some(syst)) identify("user/") should be(Some(user)) - identify("deadLetters/") should be(Some(system.deadLetters)) identify("system/") should be(Some(syst)) } - "return deadLetters or ActorIdentity(None), respectively, for non-existing paths" in { + "return ActorIdentity(None), respectively, for non-existing paths, and deadLetters" in { identify("a/b/c") should be(None) identify("a/b/c") should be(None) identify("akka://all-systems/Nobody") should be(None) identify("akka://all-systems/user") should be(None) identify(system / "hallo") should be(None) + identify("foo://user") should be(None) + identify("/deadLetters") should be(None) + identify("deadLetters") should be(None) + identify("deadLetters/") should be(None) } } diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index b11e144c35..34b6f4fef6 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -538,7 +538,7 @@ private[akka] class DeadLetterActorRef(_provider: ActorRefProvider, override def !(message: Any)(implicit sender: ActorRef = this): Unit = message match { case null ⇒ throw new InvalidMessageException("Message is null") - case Identify(messageId) ⇒ sender ! ActorIdentity(messageId, Some(this)) + case Identify(messageId) ⇒ sender ! ActorIdentity(messageId, None) case d: DeadLetter ⇒ if (!specialHandle(d.message, d.sender)) eventStream.publish(d) case _ ⇒ if (!specialHandle(message, sender)) eventStream.publish(DeadLetter(message, if (sender eq Actor.noSender) provider.deadLetters else sender, this)) diff --git a/akka-contrib/src/test/java/akka/contrib/pattern/ReliableProxyTest.java b/akka-contrib/src/test/java/akka/contrib/pattern/ReliableProxyTest.java index 012a5225c8..0fb88fcec7 100644 --- a/akka-contrib/src/test/java/akka/contrib/pattern/ReliableProxyTest.java +++ b/akka-contrib/src/test/java/akka/contrib/pattern/ReliableProxyTest.java @@ -92,7 +92,7 @@ public class ReliableProxyTest { @Test public void demonstrateTransitions() { - final ActorRef target = system.deadLetters(); + final ActorRef target = TestProbe.apply(system).ref(); final ActorRef parent = system.actorOf(Props.create(ProxyTransitionParent.class, target.path())); final TestProbe probe = TestProbe.apply(system); parent.tell("hello", probe.ref()); diff --git a/akka-contrib/src/test/scala/akka/contrib/pattern/ReliableProxyDocSpec.scala b/akka-contrib/src/test/scala/akka/contrib/pattern/ReliableProxyDocSpec.scala index ba10e35be9..38b888a578 100644 --- a/akka-contrib/src/test/scala/akka/contrib/pattern/ReliableProxyDocSpec.scala +++ b/akka-contrib/src/test/scala/akka/contrib/pattern/ReliableProxyDocSpec.scala @@ -8,6 +8,7 @@ import akka.testkit.AkkaSpec import akka.actor._ import akka.testkit.ImplicitSender import scala.concurrent.duration._ +import akka.testkit.TestProbe object ReliableProxyDocSpec { @@ -41,26 +42,50 @@ object ReliableProxyDocSpec { } } //#demo-transition + + class WatchingProxyParent(targetPath: ActorPath) extends Actor { + val proxy = context.watch(context.actorOf( + ReliableProxy.props(targetPath, 100.millis, reconnectAfter = 500.millis, maxReconnects = 3))) + + var client: Option[ActorRef] = None + + def receive = { + case "hello" ⇒ + proxy ! "world!" + client = Some(sender()) + case Terminated(`proxy`) ⇒ + client foreach { _ ! "terminated" } + } + } } -class ReliableProxyDocSpec extends AkkaSpec with ImplicitSender { +class ReliableProxyDocSpec extends AkkaSpec { import ReliableProxyDocSpec._ "A ReliableProxy" must { "show usage" in { - val target = testActor - val a = system.actorOf(Props(classOf[ProxyParent], target.path)) - a ! "hello" - expectMsg("world!") + val probe = TestProbe() + val a = system.actorOf(Props(classOf[ProxyParent], probe.ref.path)) + a.tell("hello", probe.ref) + probe.expectMsg("world!") } "show state transitions" in { - val target = system.deadLetters + val target = TestProbe().ref + val probe = TestProbe() val a = system.actorOf(Props(classOf[ProxyTransitionParent], target.path)) - a ! "go" - expectMsg("done") + a.tell("go", probe.ref) + probe.expectMsg("done") + } + + "show terminated after maxReconnects" in { + val target = system.deadLetters + val probe = TestProbe() + val a = system.actorOf(Props(classOf[WatchingProxyParent], target.path)) + a.tell("hello", probe.ref) + probe.expectMsg("terminated") } }