diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/PageBlobInputStream.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/PageBlobInputStream.java index 097201b2af..aaac490413 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/PageBlobInputStream.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/PageBlobInputStream.java @@ -343,9 +343,9 @@ private long skipImpl(long n) throws IOException { // 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;