mirror of https://github.com/apache/lucene.git
SOLR-13454: Fix the method's behavior which caused test failures due to collections disappearing during iteration.
This commit is contained in:
parent
13d1c113c1
commit
6f309dfa66
|
@ -353,10 +353,19 @@ public class ClusterState implements JSONWriter.Writable {
|
||||||
public Map<String, CollectionRef> getCollectionStates() {
|
public Map<String, CollectionRef> getCollectionStates() {
|
||||||
return immutableCollectionStates;
|
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) {
|
public void forEachCollection(Consumer<DocCollection> consumer) {
|
||||||
collectionStates.forEach((s, collectionRef) -> {
|
collectionStates.forEach((s, collectionRef) -> {
|
||||||
try {
|
try {
|
||||||
consumer.accept(collectionRef.get());
|
DocCollection collection = collectionRef.get();
|
||||||
|
if (collection != null) {
|
||||||
|
consumer.accept(collection);
|
||||||
|
}
|
||||||
} catch (SolrException e) {
|
} catch (SolrException e) {
|
||||||
if (e.getCause() instanceof KeeperException.NoNodeException) {
|
if (e.getCause() instanceof KeeperException.NoNodeException) {
|
||||||
//don't do anything. This collection does not exist
|
//don't do anything. This collection does not exist
|
||||||
|
|
Loading…
Reference in New Issue