You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/05/15 00:03:42 UTC
[GitHub] [incubator-hudi] nsivabalan commented on a change in pull request #1616: [HUDI-786] Fixing read beyond inline length in InlineFS
nsivabalan commented on a change in pull request #1616:
URL: https://github.com/apache/incubator-hudi/pull/1616#discussion_r425494577
##########
File path: hudi-common/src/main/java/org/apache/hudi/common/fs/inline/InLineFsDataInputStream.java
##########
@@ -56,24 +56,29 @@ public long getPos() throws IOException {
@Override
public int read(long position, byte[] buffer, int offset, int length) throws IOException {
+ if ((length - offset) > this.length) {
+ throw new IOException("Attempting to read past inline content");
+ }
return outerStream.read(startOffset + position, buffer, offset, length);
}
@Override
public void readFully(long position, byte[] buffer, int offset, int length) throws IOException {
+ if ((length - offset) > this.length) {
+ throw new IOException("Attempting to read past inline content");
+ }
outerStream.readFully(startOffset + position, buffer, offset, length);
}
@Override
public void readFully(long position, byte[] buffer)
throws IOException {
- outerStream.readFully(startOffset + position, buffer, 0, buffer.length);
+ readFully(position, buffer, 0, buffer.length);
}
@Override
public boolean seekToNewSource(long targetPos) throws IOException {
Review comment:
have fixed seek(targetpos). Trying to understand seekToNewSource(long targetPos). Docs says "Seek to the given position on an alternate copy of the data. Returns true if alternate copy is found, false otherwise". I am not sure how to go about this.
If we check for bounds and could return false (if targetPos > length), but what in case alternate copy is not found?
Or I could do something like this.
@Override
public boolean seekToNewSource(long targetPos) throws IOException {
boolean returnVal = outerStream.seekToNewSource(startOffset + targetPos)
if(returnVal) {
if(targetPos > length ) {
returnVal = false
}
}
return returnVal;
}
----------------------------------------------------------------
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:
users@infra.apache.org