-
Notifications
You must be signed in to change notification settings - Fork 237
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
ByteBuffer.array() cannot always be used #837
Comments
Makes sense. If you want to raise a PR I would cut a release. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is recommended to call ByteBuffer.hasArray before calling ByteBuffer.array()
avro4s calls array() in quite a few places.
https://github.com/search?q=repo%3Asksamuel%2Favro4s%20array()&type=code
See javadoc:
https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html#array--
Calling array() on a ByteBuffer that hasArray=false (eg a read-only byte buffer) will lead to an exception.
In the cases where hasArray=false, a decision needs to be made over whether you can iterate over the bytes of the Buffer using other ByteBuffer methods or whether you could do something like wrap the ByteBuffer in an enclosing class - eg something like ByteBufferBackedInputStream
The text was updated successfully, but these errors were encountered: