Apache Solr open-source search software
LUCENE-4976: fix Solr IndexDeletionPolicy impls to handle empty commits onInit
Michael McCandlessa7bcad65ebc2
diff --git a/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java b/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.javaindex 57692e845c0..21de0db6009 100644--- a/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java+++ b/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java@@ -237,7 +237,9 @@ public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy {map.put(wrapper.delegate.getGeneration(), wrapper.delegate);}solrVersionVsCommits = map;- latestCommit = ((list.get(list.size() - 1)).delegate);+ if (!list.isEmpty()) {+ latestCommit = ((list.get(list.size() - 1)).delegate);+ }}public static long getCommitTimestamp(IndexCommit commit) throws IOException {diff --git a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.javaindex bdfc8f3950e..3702d4b9b00 100644--- a/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java+++ b/solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java@@ -79,6 +79,9 @@ public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedList@Overridepublic void onInit(List commits) throws IOException {// SOLR-4547: log basic data at INFO, add filenames at DEBUG.+ if (commits.isEmpty()) {+ return;+ }log.info("SolrDeletionPolicy.onInit: commits: {}",new CommitsLoggingInfo(commits));log.debug("SolrDeletionPolicy.onInit: commits: {}",