Open d-t-w opened 10 years ago
I've looked into it and I think the problem is in https://github.com/ztellman/gloss/blob/0.2.2/src/gloss/data/bytes/core.clj#L236. On a SingleBufferSequence, the limit of the ByteBuffer is set to the minimum of the byte-count or n. I think it should be something like the limit being set to the position + byte-count or n. I'll look into this further to see if I can make a patch.
When using gloss.io/contiguous as a convenience for rolling a sequence of ByteBuffer into a single buffer I've found that:
then the output loses as many bytes from the end as the position is offset from the start.
e.g.
Two test buffers:
Apply contiguous, result is as expected:
Reset the buffers, set position on both, apply contiguous. Result is as expected:
Reset buff-a, set position, apply contiguous. Result is two bytes short, missing from the end:
As long as there is a second buffer in the sequence, this isn't an issue:
TL:DR; If using gloss.io/contiguous with non-zero position ByteBuffer sequences you might lose data.
When I get a moment I'll see if I can figure out why and raise a PR.