bytebuffer length calculation in TBinaryProtocol writeBinary
------------------------------------------------------------
Key: THRIFT-1101
URL: https://issues.apache.org/jira/browse/THRIFT-1101
Project: Thrift
Issue Type: Bug
Components: Java - Library
Reporter: Dave
In TBinaryProtocol writeBinary, the length calculation appears incorrect:
length = bin.limit() - bin.position() - bin.arrayOffset();
This subtraction of arrayOffset can cause a negative length on a sliced buffer.
For example:
ByteBuffer b = ByteBuffer.allocate(15);
b.put("1234567890".getBytes());
ByteBuffer b2 = b.slice();
b2.put("testx".getBytes());
b2.rewind();
So b2's length is lim-pos-offset = 5-0-10 = -5.
I believe we just want lim-pos.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira