lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1558459 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
Date Wed, 15 Jan 2014 16:44:25 GMT
Author: markrmiller
Date: Wed Jan 15 16:44:25 2014
New Revision: 1558459

URL: http://svn.apache.org/r1558459
Log:
SOLR-5632: Improve response message for reloading a non-existent core.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1558459&r1=1558458&r2=1558459&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Jan 15 16:44:25 2014
@@ -266,6 +266,9 @@ Other Changes
 * SOLR-2794: change the default of hl.phraseLimit to 5000.
   (Michael Della Bitta via Robert Muir, Koji, zarni - pull request #11)
 
+* SOLR-5632: Improve response message for reloading a non-existent core.
+  (Anshum Gupta via Mark Miller)
+
 ==================  4.6.1  ==================
 
 Versions of Major Components

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1558459&r1=1558458&r2=1558459&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
Wed Jan 15 16:44:25 2014
@@ -725,6 +725,11 @@ public class CoreAdminHandler extends Re
   protected void handleReloadAction(SolrQueryRequest req, SolrQueryResponse rsp) {
     SolrParams params = req.getParams();
     String cname = params.get(CoreAdminParams.CORE);
+
+    if(coreContainer.getCore(cname) == null) {
+      throw new SolrException(ErrorCode.BAD_REQUEST, "Core with core name [" + cname + "]
does not exist.");
+    }
+
     try {
       coreContainer.reload(cname);
     } catch (Exception ex) {
@@ -775,7 +780,7 @@ public class CoreAdminHandler extends Re
             
             core.getUpdateHandler().getSolrCoreState().doRecovery(coreContainer, core.getCoreDescriptor());
           } else {
-            SolrException.log(log, "Cound not find core to call recovery:" + cname);
+            SolrException.log(log, "Could not find core to call recovery:" + cname);
           }
         } finally {
           // no recoveryStrat close for now

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java?rev=1558459&r1=1558458&r2=1558459&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
Wed Jan 15 16:44:25 2014
@@ -274,4 +274,20 @@ public class CoreAdminHandlerTest extend
     }
   }
 
+  @Test
+  public void testNonexistentCoreReload() throws Exception {
+    final CoreAdminHandler admin = new CoreAdminHandler(h.getCoreContainer());
+    SolrQueryResponse resp = new SolrQueryResponse();
+
+    try {
+      admin.handleRequestBody(
+          req(CoreAdminParams.ACTION,
+              CoreAdminParams.CoreAdminAction.RELOAD.toString(),
+              CoreAdminParams.CORE, "non-existent-core")
+          , resp);
+      fail("Was able to successfully reload non-existent-core");
+    } catch (Exception e) {
+      assertEquals("Expected error message for non-existent core.", "Core with core name
[non-existent-core] does not exist.", e.getMessage());
+    }
+  }
 }



Mime
View raw message