chaokunyang commented on code in PR #1483:
URL: https://github.com/apache/incubator-fury/pull/1483#discussion_r1557623575


##########
java/fury-core/src/main/java/org/apache/fury/io/FuryReadableChannel.java:
##########
@@ -128,21 +128,21 @@ public void readToUnsafe(Object target, long 
targetPointer, int numBytes) {
 
   @Override
   public void readToByteBuffer(ByteBuffer dst, int length) {
-    readToByteBuffer0(dst, length);
+    MemoryBuffer buf = memoryBuffer;
+    int remaining = buf.remaining();
+    if (remaining < length) {
+      remaining += fillBuffer(length - remaining);
+    }
+    buf.read(dst, remaining);
   }
 
   @Override
   public int readToByteBuffer(ByteBuffer dst) {
-    return readToByteBuffer0(dst, dst.remaining());
-  }
-
-  private int readToByteBuffer0(ByteBuffer dst, int length) {
     MemoryBuffer buf = memoryBuffer;
     int remaining = buf.remaining();
-    if (remaining < length) {
-      remaining += fillBuffer(length - remaining);
+    if (remaining > 0) {
+      buf.read(dst, remaining);

Review Comment:
   If there are no remaining in `memoryBuffer`, and `channel` has extra data, 
the invocation will stop read anything here.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to