我正面临一个奇怪的例外
java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success
at java.lang.Class.cast(Class.java:3094) ~[na:1.7.0_45]
at scala.concurrent.Future$$anonfun$mapTo$1.apply(Future.scala:405) ~[scala-library.jar:na]
at scala.util.Success$$anonfun$map$1.apply(Try.scala:206) ~[scala-library.jar:na]
at scala.util.Try$.apply(Try.scala:161) ~[scala-library.jar:na]
at scala.util.Success.map(Try.scala:206) ~[scala-library.jar:na]
问题出在尾随的 $ - 比如内部类左右..
我的代码如下:
post {
authenticate(BasicAuth(pifUserPasswordAuthenticator _, realm = "bd pif import api")) {
user =>
entity(as[Array[Byte]]) { e =>
val resp = pifImportService.ask(PifTransactions("storeId","dob",e)).mapTo[akka.actor.Status.Success]
complete {
resp
}
}
}
}
因为我的演员回复如下:
Try(kafkaProducer.send(payload)) match {
case Success(_) =>
log.debug(s"$storeId - $dob - sending payload sucessfully sended to kafka")
sender() ! akka.actor.Status.Success
case Failure(throwable) =>
log.debug(s"$storeId - $dob - sending payload attempt failed $throwable")
sender() ! akka.actor.Status.Failure(throwable)
}
我错过了任何技巧还是我在这里使用了错误的名字?
谢谢