mirror of https://github.com/apache/lucene.git
SOLR-13784: EmbeddedSolrServer coreName optional
(cherry picked from commit 0d0af505a0
)
This commit is contained in:
parent
f43909111f
commit
74cfacee96
|
@ -119,6 +119,8 @@ Improvements
|
|||
|
||||
* SOLR-13638: Add debug, trace logging to RuleBasedAuthorizationPlugin (Jason Gerlowski)
|
||||
|
||||
* SOLR-13784: EmbeddedSolrServer's defaultCore constructor argument is now optional (David Smiley)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
|
@ -74,7 +73,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
* Create an EmbeddedSolrServer using a given solr home directory
|
||||
*
|
||||
* @param solrHome the solr home directory
|
||||
* @param defaultCoreName the core to route requests to by default
|
||||
* @param defaultCoreName the core to route requests to by default (optional)
|
||||
*/
|
||||
public EmbeddedSolrServer(Path solrHome, String defaultCoreName) {
|
||||
this(load(new CoreContainer(SolrXmlConfig.fromSolrHome(solrHome))), defaultCoreName);
|
||||
|
@ -84,7 +83,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
* Create an EmbeddedSolrServer using a NodeConfig
|
||||
*
|
||||
* @param nodeConfig the configuration
|
||||
* @param defaultCoreName the core to route requests to by default
|
||||
* @param defaultCoreName the core to route requests to by default (optional)
|
||||
*/
|
||||
public EmbeddedSolrServer(NodeConfig nodeConfig, String defaultCoreName) {
|
||||
this(load(new CoreContainer(nodeConfig)), defaultCoreName);
|
||||
|
@ -109,14 +108,12 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
* {@link #close()} is called.
|
||||
*
|
||||
* @param coreContainer the core container
|
||||
* @param coreName the core to route requests to by default
|
||||
* @param coreName the core to route requests to by default (optional)
|
||||
*/
|
||||
public EmbeddedSolrServer(CoreContainer coreContainer, String coreName) {
|
||||
if (coreContainer == null) {
|
||||
throw new NullPointerException("CoreContainer instance required");
|
||||
}
|
||||
if (Strings.isNullOrEmpty(coreName))
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Core name cannot be empty");
|
||||
this.coreContainer = coreContainer;
|
||||
this.coreName = coreName;
|
||||
_parser = new SolrRequestParsers(null);
|
||||
|
@ -150,8 +147,13 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
}
|
||||
}
|
||||
|
||||
if (coreName == null)
|
||||
if (coreName == null) {
|
||||
coreName = this.coreName;
|
||||
if (coreName == null) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
||||
"No core specified on request and no default core has been set.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for cores action
|
||||
SolrQueryRequest req = null;
|
||||
|
|
|
@ -69,7 +69,6 @@ import org.apache.solr.common.cloud.DocCollection;
|
|||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Replica.State;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.CollectionAdminParams;
|
||||
import org.apache.solr.common.util.ExecutorUtil;
|
||||
import org.apache.solr.common.util.IOUtils;
|
||||
import org.apache.solr.common.util.SolrjNamedThreadFactory;
|
||||
|
@ -844,7 +843,7 @@ public class CoreContainer {
|
|||
name = "localhost";
|
||||
}
|
||||
cloudManager = null;
|
||||
client = new EmbeddedSolrServer(this, CollectionAdminParams.SYSTEM_COLL) {
|
||||
client = new EmbeddedSolrServer(this, null) {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// do nothing - we close the container ourselves
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MergeIndexesEmbeddedTest extends MergeIndexesExampleTestBase {
|
|||
|
||||
@Override
|
||||
protected SolrClient getSolrAdmin() {
|
||||
return new EmbeddedSolrServer(cores, "core0");
|
||||
return new EmbeddedSolrServer(cores, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,13 +47,9 @@ public class TestSolrProperties extends AbstractEmbeddedSolrServerTestCase {
|
|||
RuleChain.outerRule(new SystemPropertiesRestoreRule());
|
||||
|
||||
protected SolrClient getSolrAdmin() {
|
||||
return new EmbeddedSolrServer(cores, "core0");
|
||||
return new EmbeddedSolrServer(cores, null);
|
||||
}
|
||||
|
||||
protected SolrClient getRenamedSolrAdmin() {
|
||||
return new EmbeddedSolrServer(cores, "renamed_core");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperties() throws Exception {
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
|
|||
*/
|
||||
|
||||
protected SolrClient getSolrAdmin() {
|
||||
return new EmbeddedSolrServer(cores, "core0");
|
||||
return new EmbeddedSolrServer(cores, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue