chaokunyang commented on code in PR #1483:
URL: https://github.com/apache/incubator-fury/pull/1483#discussion_r1557624666
##########
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:
> Did you mean `dst.remaining()`?
`Channel` doesn't have an `available` method, we can just invoke
`Channle.read` instead
--
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]