You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2019/05/14 17:42:40 UTC

[lucene-solr] 01/02: SOLR-13454: Fix the method's behavior which caused test failures due to collections disappearing during iteration.

This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 12957fcd22bc496668abbe385e8ba61196c211ec
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Tue May 14 14:09:24 2019 +0200

    SOLR-13454: Fix the method's behavior which caused test failures due to collections disappearing during iteration.
---
 .../src/java/org/apache/solr/common/cloud/ClusterState.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 970d95d..9907b9c 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -353,10 +353,19 @@ public class ClusterState implements JSONWriter.Writable {
   public Map<String, CollectionRef> getCollectionStates() {
     return immutableCollectionStates;
   }
+
+  /**
+   * Iterate over collections. Unlike {@link #getCollectionStates()} collections passed to the
+   * consumer are guaranteed to exist.
+   * @param consumer collection consumer.
+   */
   public void forEachCollection(Consumer<DocCollection> consumer) {
     collectionStates.forEach((s, collectionRef) -> {
       try {
-        consumer.accept(collectionRef.get());
+        DocCollection collection = collectionRef.get();
+        if (collection != null) {
+          consumer.accept(collection);
+        }
       } catch (SolrException e) {
         if (e.getCause() instanceof KeeperException.NoNodeException) {
           //don't do anything. This collection does not exist