Skip to content

Commit 4cb9324

Browse files
committed
MessageBuffer.base != null check should all call hasArray for ease of future change
1 parent 51e4a0a commit 4cb9324

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ else if (e.getCause() instanceof Error) {
325325

326326
public static void releaseBuffer(MessageBuffer buffer)
327327
{
328-
if (isUniversalBuffer || buffer.base != null) {
328+
if (isUniversalBuffer || buffer.hasArray()) {
329329
// We have nothing to do. Wait until the garbage-collector collects this array object
330330
}
331331
else if (DirectBufferAccess.isDirectByteBufferInstance(buffer.reference)) {
@@ -536,7 +536,7 @@ else if (src.hasArray()) {
536536
src.position(src.position() + len);
537537
}
538538
else {
539-
if (base != null) {
539+
if (hasArray()) {
540540
src.get((byte[]) base, index, len);
541541
}
542542
else {
@@ -561,7 +561,7 @@ public void putMessageBuffer(int index, MessageBuffer src, int srcOffset, int le
561561
*/
562562
public ByteBuffer sliceAsByteBuffer(int index, int length)
563563
{
564-
if (base != null) {
564+
if (hasArray()) {
565565
return ByteBuffer.wrap((byte[]) base, (int) ((address - ARRAY_BYTE_BASE_OFFSET) + index), length);
566566
}
567567
else {

0 commit comments

Comments
 (0)