lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject [lucene-solr] branch branch_8x updated: SOLR-13784: EmbeddedSolrServer coreName optional
Date Wed, 25 Sep 2019 15:33:06 GMT
This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 74cface  SOLR-13784: EmbeddedSolrServer coreName optional
74cface is described below

commit 74cfacee96e646373abc267a4ba48c05a326c442
Author: David Smiley <dsmiley@salesforce.com>
AuthorDate: Wed Sep 25 11:33:28 2019 -0400

    SOLR-13784: EmbeddedSolrServer coreName optional
    
    (cherry picked from commit 0d0af505a034a04e3d86cd24447b5a747bfa23c0)
---
 solr/CHANGES.txt                                         |  2 ++
 .../solr/client/solrj/embedded/EmbeddedSolrServer.java   | 16 +++++++++-------
 .../src/java/org/apache/solr/core/CoreContainer.java     |  3 +--
 .../client/solrj/embedded/MergeIndexesEmbeddedTest.java  |  2 +-
 .../solr/client/solrj/embedded/TestSolrProperties.java   |  6 +-----
 .../apache/solr/client/solrj/request/TestCoreAdmin.java  |  2 +-
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 093c524..48f250e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
 ----------------------
 
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
index 81cf374..db4396f 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
@@ -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;
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 5e67120..e4fa088 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -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
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
index 6a1ab9bd..85279d7 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
@@ -52,7 +52,7 @@ public class MergeIndexesEmbeddedTest extends MergeIndexesExampleTestBase
{
 
   @Override
   protected SolrClient getSolrAdmin() {
-    return new EmbeddedSolrServer(cores, "core0");
+    return new EmbeddedSolrServer(cores, null);
   }
 
   @Override
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
index 6972d96..30ddfc9 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
@@ -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 {
 
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
index 0cf59b7..44247a7 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
@@ -82,7 +82,7 @@ public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
   */
 
   protected SolrClient getSolrAdmin() {
-    return new EmbeddedSolrServer(cores, "core0");
+    return new EmbeddedSolrServer(cores, null);
   }
 
   @Test


Mime
View raw message