mirror of https://github.com/apache/lucene.git
SOLR-7866: Harden code to prevent an unhandled NPE when trying to determine the max value of the version field.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1694385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a42e164b3d
commit
7cdc63f3d4
|
@ -282,6 +282,9 @@ Bug Fixes
|
|||
* SOLR-7818: Fixed distributed stats to be calculated for all the query terms. Earlier the stats were calculated with
|
||||
the terms that are present in the last shard of a distributed request. (Varun Thacker, Anshum Gupta)
|
||||
|
||||
* SOLR-7866: VersionInfo caused an unhandled NPE when trying to determine the max value for the
|
||||
version field. (Timothy Potter)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -231,8 +231,9 @@ public class VersionInfo {
|
|||
// if indexed, then we have terms to get the max from
|
||||
if (versionField.indexed()) {
|
||||
Terms versionTerms = searcher.getLeafReader().terms(versionFieldName);
|
||||
if (versionTerms != null) {
|
||||
maxVersionInIndex = NumericUtils.getMaxLong(versionTerms);
|
||||
Long max = (versionTerms != null) ? NumericUtils.getMaxLong(versionTerms) : null;
|
||||
if (max != null) {
|
||||
maxVersionInIndex = max.longValue();
|
||||
log.info("Found MAX value {} from Terms for {} in index", maxVersionInIndex, versionFieldName);
|
||||
} else {
|
||||
log.info("No terms found for {}, cannot seed version bucket highest value from index", versionFieldName);
|
||||
|
|
|
@ -88,6 +88,11 @@ public class DistributedVersionInfoTest extends AbstractFullDistribZkTestBase {
|
|||
List<Replica> notLeaders =
|
||||
ensureAllReplicasAreActive(testCollectionName, shardId, 1, rf, maxWaitSecsToSeeAllActive);
|
||||
|
||||
// start by reloading the empty collection so we try to calculate the max from an empty index
|
||||
reloadCollection(leader, testCollectionName);
|
||||
notLeaders =
|
||||
ensureAllReplicasAreActive(testCollectionName, shardId, 1, rf, maxWaitSecsToSeeAllActive);
|
||||
|
||||
sendDoc(1);
|
||||
cloudClient.commit();
|
||||
|
||||
|
|
Loading…
Reference in New Issue