You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2015/04/15 17:16:26 UTC

svn commit: r1673823 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java

Author: shaie
Date: Wed Apr 15 15:16:25 2015
New Revision: 1673823

URL: http://svn.apache.org/r1673823
Log:
SOLR-7401: fixed NPE when concurrently creating and deleting collections

Added:
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
      - copied unchanged from r1673813, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConcurrentDeleteAndCreateCollectionTest.java
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/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.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=1673823&r1=1673822&r2=1673823&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Apr 15 15:16:25 2015
@@ -67,6 +67,9 @@ Bug Fixes
 * SOLR-7385: The clusterstatus API now returns the config set used to create a collection
   inside a 'configName' key. (Shai Erera, shalin)
 
+* SOLR-7401: Fixed a NullPointerException when concurrently creating and deleting collections,
+  while accessing other collections. (Shai Erera)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1673823&r1=1673822&r2=1673823&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Wed Apr 15 15:16:25 2015
@@ -666,13 +666,13 @@ public class SolrDispatchFilter extends
       slices = new ArrayList<>();
       // look by core name
       byCoreName = true;
-      slices = getSlicesForCollections(clusterState, slices, true);
-      if (slices == null || slices.size() == 0) {
-        slices = getSlicesForCollections(clusterState, slices, false);
+      getSlicesForCollections(clusterState, slices, true);
+      if (slices.isEmpty()) {
+        getSlicesForCollections(clusterState, slices, false);
       }
     }
     
-    if (slices == null || slices.size() == 0) {
+    if (slices.isEmpty()) {
       return null;
     }
     
@@ -723,17 +723,23 @@ public class SolrDispatchFilter extends
     return null;
   }
 
-  private Collection<Slice> getSlicesForCollections(ClusterState clusterState,
+  private void getSlicesForCollections(ClusterState clusterState,
       Collection<Slice> slices, boolean activeSlices) {
-    Set<String> collections = clusterState.getCollections();
-    for (String collection : collections) {
-      if (activeSlices) {
-        slices.addAll(clusterState.getActiveSlices(collection));
-      } else {
-        slices.addAll(clusterState.getSlices(collection));
+    if (activeSlices) {
+      for (String collection : clusterState.getCollections()) {
+        final Collection<Slice> activeCollectionSlices = clusterState.getActiveSlices(collection);
+        if (activeCollectionSlices != null) {
+          slices.addAll(activeCollectionSlices);
+        }
+      }
+    } else {
+      for (String collection : clusterState.getCollections()) {
+        final Collection<Slice> collectionSlices = clusterState.getSlices(collection);
+        if (collectionSlices != null) {
+          slices.addAll(collectionSlices);
+        }
       }
     }
-    return slices;
   }
 
   private SolrCore getCoreByCollection(CoreContainer cores, String corename) {