Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ public LocalFileReader(String path) throws Exception {

public byte[] read(long offset, int length) {
try {
dataInputStream.skip(offset);
long targetSkip = offset;
// comments from skip API:
// The skip method may, for a variety of reasons,
// end up skipping over some smaller number of bytes, possibly 0
// the result should be checked and try again until skip expectation length
while (targetSkip > 0) {
long realSkip = dataInputStream.skip(targetSkip);
if (realSkip == -1) {
throw new RuntimeException("Unexpected EOF when skip bytes");
}
targetSkip -= realSkip;
if (targetSkip > 0) {
LOG.warn("Got unexpected skip for path:" + path + " with offset["
+ offset + "], length[" + length + "], remain[" + targetSkip + "]");
}
}
byte[] buf = new byte[length];
dataInputStream.readFully(buf);
return buf;
Expand Down