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

UnsafeBuffer does not respect wrapped buffer ordering #40

Closed
nitsanw opened this issue Oct 30, 2015 · 1 comment
Closed

UnsafeBuffer does not respect wrapped buffer ordering #40

nitsanw opened this issue Oct 30, 2015 · 1 comment

Comments

@nitsanw
Copy link
Contributor

nitsanw commented Oct 30, 2015

An UnsafeBuffer can wrap, or be constructed using an existing ByteBuffer. A ByteBuffer has an ordering (or rather a 'bigEndian' flag) but an UnsafeBuffer does not. This can yield some surprise should a ByteBuffer setup to a particular ordering (via ByteBuffer.ordering(ByteOrder)) be wrapped by an UnsafeBuffer.
UnsafeBuffer currently handles ordering as a JVM wide choice (via the NATIVE_BYTE_ORDER constant). We should either document this discrepancy (I think sprinkling some javadocs would be suffecient) or accommodate ordering choice by buffer.

@mjpt777
Copy link
Contributor

mjpt777 commented Oct 30, 2015

UnsafeBuffer does not store state like ByteBuffer. This makes it thread safe. If you wish to set byte ordering other than the native setting then all the accessors have overloads.

I agree that some Javadoc is the best option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants