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 22:01:37 UTC

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

Author: markrmiller
Date: Tue Jan  6 21:01:37 2015
New Revision: 1649949

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

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1649949&r1=1649948&r2=1649949&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Tue Jan  6 21:01:37 2015
@@ -368,6 +368,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/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1649949&r1=1649948&r2=1649949&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Tue Jan  6 21:01:37 2015
@@ -270,6 +270,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;
@@ -451,9 +452,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
@@ -524,7 +528,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);
+          }
         }
       }
 
@@ -582,7 +590,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);
+                }
               }
             }
           }
@@ -865,7 +877,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) {