Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
ProtobufDecoder assumes number of bytes in delimited format will not be split into chunks [SPR-17429] #21962
Following the introduction of Protobuf (de)serialization in #20331 the deserialisation process assumes two things which are invalid:
- DataBuffer behaves like InputStream (returns -1 when no data left)
- Data in DataBuffer will somehow magically avoid splitting bytes that represent messageBytesToRead across two separate DataBuffer instances (which can happen in practice. I actually saw that the first time I ran decoding of delimited stream bigger than few items
To solve the issue I think it would be necessary to:
This is obviously just one proposed solution, there's many that will work equally well.
To reproduce the issue a sample test would have to be created similar to the test "decodeSplitChunks()" in spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java
that would split the initial and/or subsequent messageBytesToRead varint32 into separate DataBuffers. For that the sample messages sizes may have to be increased significantly. Also it would be good to add a test that verifies that a messageBytesToRead that has got varint32 representation starting with a byte value -1 (as int) is not throwing exception.
Please let me know if you need any further details or help in preparing reproducing test and/or solution.
Affects: 5.1 RC2
Referenced from: commits 91de8d2