diff --git a/CHANGES.txt b/CHANGES.txt index 6734f757a6..2a28a86ceb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.12 + * Fix potential NPE from handling result of SIM.highestSelectivityIndex (CASSANDRA-10550) * Fix paging issues with partitions containing only static columns data (CASSANDRA-10381) * Fix conditions on static columns (CASSANDRA-10264) diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java index ad3aae8ab5..12a0a555b2 100644 --- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java +++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java @@ -858,11 +858,14 @@ public class SecondaryIndexManager for (SecondaryIndexSearcher searcher : indexSearchers) { SecondaryIndex highestSelectivityIndex = searcher.highestSelectivityIndex(clause); - long estimate = highestSelectivityIndex.estimateResultRows(); - if (estimate <= bestEstimate) + if (highestSelectivityIndex != null) { - bestEstimate = estimate; - mostSelective = searcher; + long estimate = highestSelectivityIndex.estimateResultRows(); + if (estimate <= bestEstimate) + { + bestEstimate = estimate; + mostSelective = searcher; + } } } diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index f8b4f1c57f..4f20ef0273 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -1571,7 +1571,7 @@ public class StorageProxy implements StorageProxyMBean { // use our own mean column count as our estimate for how many matching rows each node will have SecondaryIndex highestSelectivityIndex = searcher.highestSelectivityIndex(command.rowFilter); - resultRowsPerRange = Math.min(resultRowsPerRange, highestSelectivityIndex.estimateResultRows()); + resultRowsPerRange = highestSelectivityIndex == null ? resultRowsPerRange : Math.min(resultRowsPerRange, highestSelectivityIndex.estimateResultRows()); } } }