HADOOP-15042. Azure PageBlobInputStream.skip() can return negative value when numberOfPagesRemaining is 0.

Contributed by Rajesh Balamohan

(cherry picked from commit 0ea182d0fa)
This commit is contained in:
Steve Loughran 2017-11-28 11:57:12 +00:00
parent 72d0be964d
commit 8bf74f325a
1 changed files with 2 additions and 2 deletions

View File

@ -343,9 +343,9 @@ final class PageBlobInputStream extends InputStream {
// Skip over whole pages as necessary without retrieving them from the
// server.
long pagesToSkipOver = Math.min(
long pagesToSkipOver = Math.max(0, Math.min(
n / PAGE_DATA_SIZE,
numberOfPagesRemaining - 1);
numberOfPagesRemaining - 1));
numberOfPagesRemaining -= pagesToSkipOver;
currentOffsetInBlob += pagesToSkipOver * PAGE_SIZE;
skipped += pagesToSkipOver * PAGE_DATA_SIZE;