Skip to content

Commit 9d5b8a4

Browse files
committed
remove redundant check
1 parent 8d6a89c commit 9d5b8a4

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

flight/flight-core/src/main/java/org/apache/arrow/flight/ArrowMessage.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ private static ArrowBuf readBuffer(BufferAllocator allocator, InputStream stream
408408
}
409409

410410
// Fall back to allocating and copying
411-
ArrowBuf buf = allocator.buffer(size);
412-
byte[] heapBytes = new byte[size];
413-
ByteStreams.readFully(stream, heapBytes);
414-
buf.writeBytes(heapBytes);
415-
buf.writerIndex(size);
416-
return buf;
411+
ArrowBuf buf = allocator.buffer(size);
412+
byte[] heapBytes = new byte[size];
413+
ByteStreams.readFully(stream, heapBytes);
414+
buf.writeBytes(heapBytes);
415+
buf.writerIndex(size);
416+
return buf;
417417
}
418418

419419
/**
@@ -453,17 +453,10 @@ static ArrowBuf wrapGrpcBuffer(
453453
}
454454

455455
// Take ownership
456-
Detachable detachable = (Detachable) stream;
457-
InputStream detachedStream = detachable.detach();
456+
InputStream detachedStream = ((Detachable) stream).detach();
458457

459458
// Get buffer from detached stream
460-
HasByteBuffer detachedHasByteBuffer = (HasByteBuffer) detachedStream;
461-
ByteBuffer detachedByteBuffer = detachedHasByteBuffer.getByteBuffer();
462-
463-
if (detachedByteBuffer == null || !detachedByteBuffer.isDirect()) {
464-
closeQuietly(detachedStream);
465-
return null;
466-
}
459+
ByteBuffer detachedByteBuffer = ((HasByteBuffer) detachedStream).getByteBuffer();
467460

468461
// Calculate memory address accounting for buffer position
469462
long baseAddress = MemoryUtil.getByteBufferAddress(detachedByteBuffer);

0 commit comments

Comments
 (0)