Fix MessageUnpacker#unpackString in case that string length is more than... by komamitsu · Pull Request #215 · msgpack/msgpack-java
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no guarantee that the read length from the input always matches Math.min(buffer.size() - position, strLen-cursor) when OVERFLOW (output buffer has insufficient space) happens. When OVERFLOW occurs, the input data might be partially read. That is why I compute readLen as bb.limit() - bb.remaining().
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I was wrong. readLen can be retrieved by bb.position() since we created a new ByteBuffer at
ByteBuffer bb = buffer.toByteBuffer(position, readLen);
whose initial position is 0.