Skip to content

Infinite sequence of END_OBJECT tokens returned at end of streaming read #135

@wanglingsong

Description

@wanglingsong

Jackson version: 2.9.4
I'm trying to use streaming JsonParser to parse protobuf binary data according to your example, however the nextToken method keep returning "END_OBJECT" token in the end of parsing. You can reproduce this issue by following code:

        ObjectMapper mapper = new ProtobufMapper();
        String protobuf_str = "message Employee {\n"
                + " required string name = 1;\n"
                + " required int32 age = 2;\n"
                + " repeated string emails = 3;\n"
                + " optional Employee boss = 4;\n"
                + "}\n";
        final ProtobufSchema schema = ProtobufSchemaLoader.std.parse(protobuf_str);

        Employee empl = new Employee();
        empl.age = 30;
        empl.emails = new String[]{"foo@gmail.com"};
        empl.name = "foo";

        byte[] protobufData = mapper.writer(schema)
                .writeValueAsBytes(empl);

        JsonParser jsonParser = new ProtobufFactory().createParser(new ByteArrayInputStream(protobufData));
        jsonParser.setSchema(schema);
        JsonToken token;
        while ((token = jsonParser.nextToken()) != null) {
            System.out.println(token.id());
        }

output:

1
5
6
5
7
5
3
6
4
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...endless

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions