From a7bcad65ebc25140d9d3ce53330cbdb929db1412 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Fri, 3 May 2013 16:12:22 +0000 Subject: [PATCH] LUCENE-4976: fix Solr IndexDeletionPolicy impls to handle empty commits onInit git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1478855 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/solr/core/IndexDeletionPolicyWrapper.java | 4 +++- .../src/java/org/apache/solr/core/SolrDeletionPolicy.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java b/solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java index 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.java index 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 @Override public 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: {}",