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/07/12 07:30:51 UTC

svn commit: r1690425 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/core/CoreContainer.java solr/core/src/test/org/apache/solr/core/TestCoreContainer.java

Author: shalin
Date: Sun Jul 12 05:30:51 2015
New Revision: 1690425

URL: http://svn.apache.org/r1690425
Log:
SOLR-7705: CoreAdminHandler Unload no longer handles null core name

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/core/CoreContainer.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.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=1690425&r1=1690424&r2=1690425&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Sun Jul 12 05:30:51 2015
@@ -164,6 +164,9 @@ Bug Fixes
 * SOLR-7172: addreplica API fails with incorrect error msg "cannot create collection"
   (Erick Erickson)
 
+* SOLR-7705: CoreAdminHandler Unload no longer handles null core name and throws NPE
+  instead of a bad request error. (John Call, Edward Ribeiro via shalin)
+
 Optimizations
 ----------------------
 
@@ -185,7 +188,6 @@ Optimizations
   (yonik)
   
 
-
 Other Changes
 ----------------------
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1690425&r1=1690424&r2=1690425&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/CoreContainer.java Sun Jul 12 05:30:51 2015
@@ -819,14 +819,16 @@ public class CoreContainer {
    */
   public void unload(String name, boolean deleteIndexDir, boolean deleteDataDir, boolean deleteInstanceDir) {
 
-    // check for core-init errors first
-    CoreLoadFailure loadFailure = coreInitFailures.remove(name);
-    if (loadFailure != null) {
-      // getting the index directory requires opening a DirectoryFactory with a SolrConfig, etc,
-      // which we may not be able to do because of the init error.  So we just go with what we
-      // can glean from the CoreDescriptor - datadir and instancedir
-      SolrCore.deleteUnloadedCore(loadFailure.cd, deleteDataDir, deleteInstanceDir);
-      return;
+    if (name != null) {
+      // check for core-init errors first
+      CoreLoadFailure loadFailure = coreInitFailures.remove(name);
+      if (loadFailure != null) {
+        // getting the index directory requires opening a DirectoryFactory with a SolrConfig, etc,
+        // which we may not be able to do because of the init error.  So we just go with what we
+        // can glean from the CoreDescriptor - datadir and instancedir
+        SolrCore.deleteUnloadedCore(loadFailure.cd, deleteDataDir, deleteInstanceDir);
+        return;
+      }
     }
 
     CoreDescriptor cd = solrCores.getCoreDescriptor(name);

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1690425&r1=1690424&r2=1690425&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Sun Jul 12 05:30:51 2015
@@ -178,6 +178,18 @@ public class TestCoreContainer extends S
         assertThat(e.getMessage(), containsString("Cannot unload non-existent core [non_existent_core]"));
       }
 
+      // try and remove a null core
+      try {
+        cores.unload(null);
+        fail("Should have thrown an exception when unloading a null core");
+      }
+      catch (Exception e) {
+        if (!(e instanceof SolrException)) {
+          fail("Should not have thrown SolrException but got " + e);
+        }
+        assertThat(e.getMessage(), containsString("Cannot unload non-existent core [null]"));
+      }
+
     } finally {
       cores.shutdown();
     }