zoltar9264 commented on code in PR #24847:
URL: https://github.com/apache/flink/pull/24847#discussion_r1615605846
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ByteBufferReadableFSDataInputStream.java:
##########
@@ -99,7 +104,23 @@ public int readFully(ByteBuffer bb) throws IOException {
public int readFully(long position, ByteBuffer bb) throws Exception {
if (bb == null) {
throw new NullPointerException();
- } else if (bb.remaining() == 0) {
+ } else if (position > totalFileSize) {
+ throw new IllegalArgumentException(
Review Comment:
The interface doc of ByteBufferReadable say "Implementations should treat
0-length requests as legitimate, and must not signal an error upon their
receipt.", It seems this change brake that ?
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ByteBufferReadableFSDataInputStream.java:
##########
@@ -99,7 +104,23 @@ public int readFully(ByteBuffer bb) throws IOException {
public int readFully(long position, ByteBuffer bb) throws Exception {
if (bb == null) {
throw new NullPointerException();
- } else if (bb.remaining() == 0) {
+ } else if (position > totalFileSize) {
+ throw new IllegalArgumentException(
+ String.format(
+ "position [%s] is larger than totalFileSize [%s]",
+ position, totalFileSize));
+ }
+
+ // Avoid bb.remaining() exceeding the file size limit.
+ bb.limit(
Review Comment:
The interface doc of ByteBufferReadable mention “Callers should use
byteBuffer. limit(...) to control the size of the desired read” and "After a
successful call, byteBuffer. position() will be advanced by the number of bytes
read and byteBuffer. limit() will be unchanged." ?
--
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]