Fix potential exception in SSTableIterator indexed reader

patch by carlyeks; reviewed by slebresne for CASSANDRA-9859
This commit is contained in:
Sylvain Lebresne 2015-07-22 18:18:23 +02:00
parent 2457599427
commit 9ddce25ff7
3 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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