大家。 A与akka unstashAll函数有意外错误。 在我的演员中,它是一个简单的函数,可以执行context.become(idle()) 比unstashAll()
private def becomeIdle(list: List[String]): Unit = {
become(idle(list))
setReceiveTimeout(Duration.Undefined)
unstashAll()
}
然后突然看到了
java.lang.NullPointerException
at akka.actor.StashSupport.$anonfun$unstashAll$2(Stash.scala:217)
at akka.actor.StashSupport.$anonfun$unstashAll$2$adapted(Stash.scala:217)
at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:502)
at akka.actor.StashSupport.unstashAll(Stash.scala:218)
at akka.actor.StashSupport.unstashAll$(Stash.scala:215)
at com.myapp.TestActor.unstashAll(TestActor.scala:23)
at akka.actor.StashSupport.unstashAll(Stash.scala:198)
at akka.actor.StashSupport.unstashAll$(Stash.scala:198)
at myapp.TestActor.unstashAll(myapp.TestActor.scala:23)
at com.myapp.TestActor.com$myapp$TestActor$becomeIdle(TestActor.scala:122)
at com.myapp.TestActor$$anonfun$awaitData$1.applyOrElse(TestActor.scala:87)
at akka.actor.Actor.aroundReceive(Actor.scala:513)
at akka.actor.Actor.aroundReceive$(Actor.scala:511)
at com.myapp.TestActor.aroundReceive(TestActor.scala:23)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:519)
at akka.actor.ActorCell.invoke(ActorCell.scala:488)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
at akka.dispatch.Mailbox.run(Mailbox.scala:224)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
我在调试器中跟踪它
Stash.scala
198 def unstashAll(): Unit = unstashAll(_ ⇒ true)
然后
215 private[akka] def unstashAll(filterPredicate: Any ⇒ Boolean): Unit = {
216 try {
217 val i = theStash.reverseIterator.filter(envelope ⇒ filterPredicate(envelope.message))
218 while (i.hasNext) enqueueFirst(i.next())
219 } finally {
220 theStash = Vector.empty[Envelope]
221 }
222 }
在字符串218处我有“Method threw'java.lang.NullPointerException'异常。无法评估scala.collection.iterator $$ anon $ 12.toString()
我声明是
hd = null
hdDefined = false
$outer = {Vector$$anon$1@9153} "empty iterator"
i = 0
$outer = {Vector@9133} "Vector" size = 1
All elements are null
p = {StashSupport$lambda@11430}
arg = {StashSupport$lambda@9140}
Class has no fields
theStash = {Vector@9133} "Vector" size = 1
All elements are null
请帮帮我!