开发者

Akka error post.request.getReader

I use akka-mist and protobuf. Language Scala. Protobuf error

Test Sender:

val (post, writer) = RestPostMock(ProtoBufPack.toByteString)
actor ? post

RestPostMock:

object RestPostMock extends Mockito {
  def 开发者_开发技巧apply(msg: ByteString): (Post, StringWriter) = {
    val httpRequest = mock[HttpServletRequest]
    httpRequest.getReader returns new BufferedReader(new StringReader(msg.toStringUtf8))
    ...

Actors:

class CarStatusActor extends Actor {
  def receive = {
    case post: Post =>
      EventHandler.info(this, "received post test>>>>>>>>>>>>>>>>>>>")
      val readerInput = new ReaderInputStream(post.request.getReader)
      val protoBufPack = ProtoBufPack.parseFrom(readerInput)
      post.OK("Ok")
  }

In result:

INFO  [akka:event-driven:dispatcher:event:handler-1] akka.event.slf4j.Slf4jEventHandler - 
    [actorhandler.CarStatusActor]
    [received post test>>>>>>>>>>>>>>>>>>>]
ERROR [akka:event-driven:dispatcher:event:handler-1] akka.event.slf4j.Slf4jEventHandler - 
    [akka.testkit.TestActorRef]
    [Mock for Post, hashCode: 1039701893]
    [com.google.protobuf.InvalidProtocolBufferException: CodedInputStream encountered a malformed varint.
    at com.google.protobuf.InvalidProtocolBufferException.malformedVarint(InvalidProtocolBufferException.java:63)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜