From 0ea182d0faa35c726dcb37249d48786bfc8ca04c Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Tue, 28 Nov 2017 11:52:59 +0000 Subject: [PATCH] HADOOP-15042. Azure PageBlobInputStream.skip() can return negative value when numberOfPagesRemaining is 0. Contributed by Rajesh Balamohan --- .../java/org/apache/hadoop/fs/azure/PageBlobInputStream.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 097201b2af3..aaac4904133 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 @@ 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;