stczwd commented on a change in pull request #9147:
URL: https://github.com/apache/arrow/pull/9147#discussion_r556234741
##########
File path:
java/flight/flight-core/src/main/java/org/apache/arrow/flight/ArrowMessage.java
##########
@@ -332,6 +333,23 @@ private static ArrowMessage frame(BufferAllocator
allocator, final InputStream s
}
+ /**
+ * Get first byte with EOF check, it is especially needed when using grpc
compression.
+ * InflaterInputStream need another read to change reachEOF after all bytes
has been read.
+ *
+ * @param is InputStream
+ * @return -1 if stream is not available, otherwise it will return the
actual value.
+ * @throws IOException Read first byte failed.
+ */
+ private static int readRawVarint32WithEOFCheck(InputStream is) throws
IOException {
+ int firstByte = is.read();
+ if (is.available() <= 0) {
+ return -1;
+ } else {
+ return CodedInputStream.readRawVarint32(firstByte, is);
+ }
+ }
+
private static int readRawVarint32(InputStream is) throws IOException {
int firstByte = is.read();
Review comment:
`readRawVarint32` is called to get tag and byte size, exception is still
needed on the byte size reading.
If the tag readed is -1, it means there's never any more data to read.
But if the size readed is -1, it means this is bad data and exception is
needed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]