SOLR-10020: CoreAdminHandler silently swallows some errors

This commit is contained in:
Erick 2017-02-21 21:59:26 -08:00
parent cf1cba66f4
commit 14b3622608
3 changed files with 22 additions and 14 deletions

View File

@ -169,6 +169,8 @@ Bug Fixes
* SOLR-10170: ClassCastException in RecoveryStrategy. (Mark Miller)
* SOLR-10020: CoreAdminHandler silently swallows some errors. (Mike Drob via Erick Erickson)
Optimizations
----------------------

View File

@ -140,21 +140,17 @@ enum CoreAdminOperation implements CoreAdminOp {
REQUESTRECOVERY_OP(REQUESTRECOVERY, it -> {
final SolrParams params = it.req.getParams();
log().info("It has been requested that we recover: core=" + params.get(CoreAdminParams.CORE));
new Thread(() -> {
String cname = params.get(CoreAdminParams.CORE);
if (cname == null) {
cname = "";
final String cname = params.get(CoreAdminParams.CORE, "");
log().info("It has been requested that we recover: core=" + cname);
try (SolrCore core = it.handler.coreContainer.getCore(cname)) {
if (core != null) {
// This can take a while, but doRecovery is already async so don't worry about it here
core.getUpdateHandler().getSolrCoreState().doRecovery(it.handler.coreContainer, core.getCoreDescriptor());
} else {
throw new SolrException(ErrorCode.BAD_REQUEST, "Unable to locate core " + cname);
}
try (SolrCore core = it.handler.coreContainer.getCore(cname)) {
if (core != null) {
core.getUpdateHandler().getSolrCoreState().doRecovery(it.handler.coreContainer, core.getCoreDescriptor());
} else {
SolrException.log(log(), "Could not find core to call recovery:" + cname);
}
}
}).start();
}
}),
REQUESTSYNCSHARD_OP(REQUESTSYNCSHARD, new RequestSyncShardOp()),

View File

@ -17,6 +17,7 @@
package org.apache.solr.client.solrj.request;
import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
@ -28,9 +29,11 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.AbstractEmbeddedSolrServerTestCase;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.request.CoreAdminRequest.RequestRecovery;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;
@ -281,6 +284,13 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
assertEquals(2, core0Registry.counter("UPDATE./update.requests").getCount());
assertEquals(3, core1Registry.counter("UPDATE./update.requests").getCount());
}
@Test
public void testInvalidRequestRecovery() throws SolrServerException, IOException {
RequestRecovery recoverRequestCmd = new RequestRecovery();
recoverRequestCmd.setCoreName("non_existing_core");
expectThrows(SolrException.class, () -> recoverRequestCmd.process(getSolrAdmin()));
}
@BeforeClass
public static void before() {