From 9ddce25ff79efae6edd42c1f2f4c78deba19b4e7 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Wed, 22 Jul 2015 18:18:23 +0200 Subject: [PATCH] Fix potential exception in SSTableIterator indexed reader patch by carlyeks; reviewed by slebresne for CASSANDRA-9859 --- CHANGES.txt | 2 +- .../cassandra/db/columniterator/AbstractSSTableIterator.java | 2 +- .../apache/cassandra/db/columniterator/SSTableIterator.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 56c34954a0..7277140667 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,7 +3,7 @@ * Metrics should use up to date nomenclature (CASSANDRA-9448) * Change CREATE/ALTER TABLE syntax for compression (CASSANDRA-8384) * Cleanup crc and adler code for java 8 (CASSANDRA-9650) - * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825, 9848) + * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825, 9848, 9705, 9859) * Update Guava to 18.0 (CASSANDRA-9653) * Bloom filter false positive ratio is not honoured (CASSANDRA-8413) * New option for cassandra-stress to leave a ratio of columns null (CASSANDRA-9522) diff --git a/src/java/org/apache/cassandra/db/columniterator/AbstractSSTableIterator.java b/src/java/org/apache/cassandra/db/columniterator/AbstractSSTableIterator.java index 8625112791..4a35e80f32 100644 --- a/src/java/org/apache/cassandra/db/columniterator/AbstractSSTableIterator.java +++ b/src/java/org/apache/cassandra/db/columniterator/AbstractSSTableIterator.java @@ -456,7 +456,7 @@ abstract class AbstractSSTableIterator implements SliceableUnfilteredRowIterator // Check if we've crossed an index boundary (based on the mark on the beginning of the index block). public boolean isPastCurrentBlock() { - return currentIndexIdx < indexes.size() && reader.file.bytesPastMark(mark) >= currentIndex().width; + return reader.file.bytesPastMark(mark) >= currentIndex().width; } public int currentBlockIdx() diff --git a/src/java/org/apache/cassandra/db/columniterator/SSTableIterator.java b/src/java/org/apache/cassandra/db/columniterator/SSTableIterator.java index a58ea3efdc..64d33dc578 100644 --- a/src/java/org/apache/cassandra/db/columniterator/SSTableIterator.java +++ b/src/java/org/apache/cassandra/db/columniterator/SSTableIterator.java @@ -252,8 +252,9 @@ public class SSTableIterator extends AbstractSSTableIterator protected Unfiltered computeNext() throws IOException { // Our previous read might have made us cross an index block boundary. If so, update our informations. - if (indexState.isPastCurrentBlock()) - indexState.setToBlock(indexState.currentBlockIdx() + 1); + int currentBlockIdx = indexState.currentBlockIdx(); + if (indexState.isPastCurrentBlock() && currentBlockIdx + 1 < indexState.blocksCount()) + indexState.setToBlock(currentBlockIdx + 1); // Return the next unfiltered unless we've reached the end, or we're beyond our slice // end (note that unless we're on the last block for the slice, there is no point