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
[warning] Byte buffer backing array warning fix #7368
[warning] Byte buffer backing array warning fix #7368
Conversation
301004c
to
7bcef77
Compare
return type.decoder().decode(stringBuffer).toString(); | ||
} catch (CharacterCodingException e) { | ||
if (type == Type.UTF16) { | ||
if (buffer.hasArray()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safe to suppress this warning -- we create and control all of the ByteBuffers here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay, Yeah we can suppress it, then the little trade-off is that now it has to keep in mind a thingy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now lme suppress it
6193705
to
103785a
Compare
@hellosagar Looks like you have pushed wrong commits to this branch, and the final result is one added line. Could you check it again? |
ohh yeah right, sorry |
103785a
to
a66bddd
Compare
@hellosagar could you rebase and squash to one commit? Thanks. |
606aa5f
to
c880b63
Compare
Overview
Tried to fix the⚠️ which is basically is avoid us to access the
ByteBufferBackingArray
.array()
because there is the possibility that it could be direct ByteBuffer (built using off-heap directly mapped to memory) too.Proposed Changes
To avoid this situation, I'm checking first if
buffer.hasArray()
which checks it doesn't have anull
byte array, and if it's not a read-only ByteBuffer(basically checking if its a heap buffer)Problem
Even after doing what is mentioned above, that warning still exists. But as soon as I invoke the
buffer.arrayOffset()
(which might throw an exception if its a heap buffer) before callingbuffer.array()
the warning is goneand if I don't call the
buffer.arrayOffset()
warning exists.Thanks for the help in advance 🙇♂️