mirror of https://github.com/apache/lucene.git
SOLR-6880: Harden ZkStateReader to expect that getCollectionLive may return null as it's contract states.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1649945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90dd4ab345
commit
bba930a5b3
|
@ -413,6 +413,8 @@ Bug Fixes
|
|||
* SOLR-6907: URLEncode documents directory in MorphlineMapperTest to handle spaces etc.
|
||||
in file name. (Ramkumar Aiyengar via Erick Erickson)
|
||||
|
||||
* SOLR-6880: Harden ZkStateReader to expect that getCollectionLive may return null
|
||||
as it's contract states. (Mark Miller, shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -273,6 +273,7 @@ public class ZkStateReader implements Closeable {
|
|||
if (collection.getZNodeVersion() < version) {
|
||||
log.debug("server older than client {}<{}", collection.getZNodeVersion(), version);
|
||||
DocCollection nu = getCollectionLive(this, coll);
|
||||
if (nu == null) return null;
|
||||
if (nu.getZNodeVersion() > collection.getZNodeVersion()) {
|
||||
updateWatchedCollection(nu);
|
||||
collection = nu;
|
||||
|
@ -454,9 +455,12 @@ public class ZkStateReader implements Closeable {
|
|||
synchronized (this) {
|
||||
if (watchedCollections.contains(s)) {
|
||||
DocCollection live = getCollectionLive(this, s);
|
||||
watchedCollectionStates.put(s, live);
|
||||
// if it is a watched collection, add too
|
||||
result.put(s, new ClusterState.CollectionRef(live));
|
||||
assert live != null;
|
||||
if (live != null) {
|
||||
watchedCollectionStates.put(s, live);
|
||||
// if it is a watched collection, add too
|
||||
result.put(s, new ClusterState.CollectionRef(live));
|
||||
}
|
||||
} else {
|
||||
// if it is not collection, then just create a reference which can fetch
|
||||
// the collection object just in time from ZK
|
||||
|
@ -527,7 +531,11 @@ public class ZkStateReader implements Closeable {
|
|||
}
|
||||
synchronized (ZkStateReader.this) {
|
||||
for (String watchedCollection : watchedCollections) {
|
||||
updateWatchedCollection(getCollectionLive(this, watchedCollection));
|
||||
DocCollection live = getCollectionLive(this, watchedCollection);
|
||||
assert live != null;
|
||||
if (live != null) {
|
||||
updateWatchedCollection(live);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,7 +593,11 @@ public class ZkStateReader implements Closeable {
|
|||
|
||||
synchronized (ZkStateReader.this) {
|
||||
for (String watchedCollection : watchedCollections) {
|
||||
updateWatchedCollection(getCollectionLive(ZkStateReader.this, watchedCollection));
|
||||
DocCollection live = getCollectionLive(ZkStateReader.this, watchedCollection);
|
||||
assert live != null;
|
||||
if (live != null) {
|
||||
updateWatchedCollection(live);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -878,7 +890,10 @@ public class ZkStateReader implements Closeable {
|
|||
};
|
||||
zkClient.exists(fullpath, watcher, true);
|
||||
}
|
||||
updateWatchedCollection(getCollectionLive(this, coll));
|
||||
DocCollection collection = getCollectionLive(this, coll);
|
||||
if (collection != null) {
|
||||
updateWatchedCollection(collection);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWatchedCollection(DocCollection newState) {
|
||||
|
|
Loading…
Reference in New Issue