Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByteBufferOutput writeVar*() changes endianness underlying nioBuffer #389

Closed
stau opened this issue Feb 22, 2016 · 2 comments
Closed

ByteBufferOutput writeVar*() changes endianness underlying nioBuffer #389

stau opened this issue Feb 22, 2016 · 2 comments

Comments

@stau
Copy link
Contributor

stau commented Feb 22, 2016

Calling writeLong()/writeInt() after writeVarLong()/writeVarInt() will write the Long/Int in little endian order, because the order() in the nioBuffer is set to little endian in writeVar*().
A certain use-case would be having a fixed-size header which contains the number of elements in the buffer, which will be written to after writing the VarLong/VarInt.

Perhaps the order() of the nioBuffer should be reverted to the original order after writeVar*() ?

@romix
Copy link
Collaborator

romix commented Feb 22, 2016

Good catch! How about submitting a PR with a test-case to ensure it does not happen in the future?

@stau
Copy link
Contributor Author

stau commented Feb 22, 2016

Upon further inspection, this case happens when the buffer overflows during a require(int), in a writeVar*() method. Before throwing the KryoException, it's possible to reset the order of the nioBuffer. I can make a PR for this.

I also noticed that setting the order/position on the BufferOutput does not set the position/order on the nioBuffer.

stau added a commit to stau/kryo that referenced this issue Feb 23, 2016
…ng writeVar*()

during writeVar*() a KryoException caused by require(int) did not revert the byteOrder
@magro magro closed this as completed in 7d840a0 Feb 24, 2016
magro added a commit that referenced this issue Feb 24, 2016
Fix #389 ByteBufferOutput: revert ByteOrder on overflow in require during writeVar*()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants