You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2015/01/06 21:53:49 UTC

svn commit: r1649945 - in /lucene/dev/trunk/solr: CHANGES.txt solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java

Author: markrmiller
Date: Tue Jan  6 20:53:49 2015
New Revision: 1649945

URL: http://svn.apache.org/r1649945
Log:
SOLR-6880: Harden ZkStateReader to expect that getCollectionLive may return null as it's contract states.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1649945&r1=1649944&r2=1649945&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Jan  6 20:53:49 2015
@@ -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
 ----------------------

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1649945&r1=1649944&r2=1649945&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Tue Jan  6 20:53:49 2015
@@ -273,6 +273,7 @@ public class ZkStateReader implements Cl
     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 Cl
       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 Cl
       }
       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 Cl
 
             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 Cl
       };
       zkClient.exists(fullpath, watcher, true);
     }
-    updateWatchedCollection(getCollectionLive(this, coll));
+    DocCollection collection = getCollectionLive(this, coll);
+    if (collection != null) {
+      updateWatchedCollection(collection);
+    }
   }
   
   private void updateWatchedCollection(DocCollection newState) {