Skip to content

readArrayBegin in org.msgpack.template.builder.ScalaBuildContext#buildReadMethodBody #15

@andypetrella

Description

@andypetrella

It might not be an issue but part of my misunderstanding of the problem.

Let me explain it before I comment the title.

I'm trying to read into a class A which has 2 fields, let's say

class A {
  var a:String
  var b:String
}

I've written a serialization of such event in a file, that I'll try to read like this:

    val openStream: InputStream = new URL("file:///temp/test").openStream()
    var events = ScalaMessagePack.read[Event](openStream)

    println(events)

And here is what I got:

Expected array, but got map value
org.msgpack.MessageTypeException: Expected array, but got map value
    at org.msgpack.unpacker.Accept.acceptMap(Accept.java:93)
    at org.msgpack.unpacker.MessagePackUnpacker.readOneWithoutStack(MessagePackUnpacker.java:132)
    at org.msgpack.unpacker.MessagePackUnpacker.readOne(MessagePackUnpacker.java:73)

This happen because the method referred in the title is always calling readArrayBegin at the start of the read. However, it look like the binary file I've written based on write is not writing an array but a map.
However, if I readAsValue the file, it will work by resulting a MapValue...

Is there something I miss, or is it a bug (which I don't believe).

Thanks for you help

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions