【发布时间】:2014-02-12 10:39:13
【问题描述】:
我正在尝试获得这样的 TestActorRef
class NotifySenderTest(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpecLike with Matchers with BeforeAndAfterAll with BeforeAndAfter {
def this() = this(ActorSystem("NotifySenderTest"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"A NotifySender" must {
"be able to process the required messages" in {
val actorRef = TestActorRef[NotifySender] //Line 92
}
}
这个演员
class NotifySender extends Actor with Stash {
import Tcp._
import context.system
def receive = {
[...]
}
}
但这给我留下了以下堆栈跟踪
java.lang.NullPointerException:在 akka.actor.dungeon.Dispatch$class.init(Dispatch.scala:62) 在 akka.actor.ActorCell.init(ActorCell.scala:338) 在 akka.actor.LocalActorRef.(ActorRef.scala:304) 在 akka.testkit.TestActorRef.(TestActorRef.scala:21) 在 akka.testkit.TestActorRef$.apply(TestActorRef.scala:141) 在 akka.testkit.TestActorRef$.apply(TestActorRef.scala:137) 在 akka.testkit.TestActorRef$.apply(TestActorRef.scala:146) 在 akka.testkit.TestActorRef$.apply(TestActorRef.scala:144) 在 actor.NotifySenderTest$$anonfun$2$$anonfun$apply$mcV$sp$4.apply$mcV$sp(NotifySenderTest.scala:92) 在 actor.NotifySenderTest$$anonfun$2$$anonfun$apply$mcV$sp$4.apply(NotifySenderTest.scala:91) ...
编辑:这似乎与这个演员特别有关。将 TestActorRef 获取到另一个演员类工作正常。我读到对于具有 Stash 特征的演员来说 TextActorRefs 存在问题,但据说在当前版本中已解决。 (Reference)
Edit2:好的。我错了。当前版本不是 2.3。所以我要等?!
【问题讨论】:
-
是的,这个问题已在 2.3.0-RC2 中修复,但由于二进制兼容性问题,我们无法将其反向移植到 2.2.x。
-
你知道2.3.0稳定版的发布日期吗?
-
“知道”很难,因为它在于未来,但目前的计划是两周后,因为我现在正在准备 RC3。