mirror of
https://github.com/apache/lucene.git
synced 2025-02-10 20:15:18 +00:00
SOLR-13454: Fix the method's behavior which caused test failures due to collections disappearing during iteration.
This commit is contained in:
parent
65d9b4979f
commit
12957fcd22
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user