Skip to content

Problem with protobuf deserializer #291

@Welkin-Y

Description

@Welkin-Y

Problem description
Hello, I am currently working on the flink-connector project trying to add protobuf support. I've noticed that after serializing a message to a ByteBuffer, if I convert it to a byte[] using .array(), and then convert it back to a ByteBuffer using ByteBuffer.wrap(), there will be an exception when passing it to the deserialize function. I noticed that in the test cases, there are no scenarios covering conversions between ByteBuffers and byte arrays. However, such a convertion is needed for flink-connector interfaces.

Problem location

To reproduce the exception, you can modify this file by changing line 84 as follows:, you can regenerate the exception by changing line 84 as follows:

c80e7a2f340e1b7d45c1a848cdf5c19

The error message is like this:

768133634d1465c845f564f4843f7e1

Suggestions for an improvement
I'm not sure if it's related to the deserialize method. From my experiments, I found that the issue arises because, after converting a ByteBuffer to a byte[] and back, the limit information of the ByteBuffer is lost, leading to a parsing error in protobuf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions