diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 243f32392c3..a199f043495 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -210,6 +210,8 @@ Improvements --------------------- * SOLR-15081: Metrics for a core: add SolrCloud "isLeader" and "replicaState". (David Smiley) +* SOLR-15085: Prevent EmbeddedSolrServer calling shutdown on a CoreContainer that was passed to it. (Tim Owen via Mike Drob) + Optimizations --------------------- * SOLR-15079: Block Collapse - Faster collapse code when groups are co-located via Block Join style nested doc indexing. 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 3c2b490bb29..62cc25e5696 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 @@ -71,6 +71,7 @@ public class EmbeddedSolrServer extends SolrClient { protected final String coreName; private final SolrRequestParsers _parser; private final RequestWriterSupplier supplier; + private boolean containerIsLocal = false; public enum RequestWriterSupplier { JavaBin(() -> new BinaryRequestWriter()), XML(() -> new RequestWriter()); @@ -94,6 +95,7 @@ public class EmbeddedSolrServer extends SolrClient { */ public EmbeddedSolrServer(Path solrHome, String defaultCoreName) { this(load(new CoreContainer(solrHome, new Properties())), defaultCoreName); + containerIsLocal = true; } /** @@ -104,6 +106,7 @@ public class EmbeddedSolrServer extends SolrClient { */ public EmbeddedSolrServer(NodeConfig nodeConfig, String defaultCoreName) { this(load(new CoreContainer(nodeConfig)), defaultCoreName); + containerIsLocal = true; } private static CoreContainer load(CoreContainer cc) { @@ -120,9 +123,6 @@ public class EmbeddedSolrServer extends SolrClient { /** * Create an EmbeddedSolrServer wrapping a CoreContainer. - *
- * Note that EmbeddedSolrServer will shutdown the wrapped CoreContainer when - * {@link #close()} is called. * * @param coreContainer the core container * @param coreName the core to route requests to by default (optional) @@ -133,8 +133,6 @@ public class EmbeddedSolrServer extends SolrClient { /** * Create an EmbeddedSolrServer wrapping a CoreContainer. - *
- * Note that EmbeddedSolrServer will shutdown the wrapped CoreContainer when {@link #close()} is called.
*
* @param coreContainer
* the core container
@@ -354,11 +352,13 @@ public class EmbeddedSolrServer extends SolrClient {
}
/**
- * Shutdown all cores within the EmbeddedSolrServer instance
+ * Closes any resources created by this instance
*/
@Override
public void close() throws IOException {
- coreContainer.shutdown();
+ if (containerIsLocal) {
+ coreContainer.shutdown();
+ }
}
/**
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 b18d2a67009..26bb7d3ac5d 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -955,12 +955,7 @@ public class CoreContainer {
name = "localhost";
}
cloudManager = null;
- client = new EmbeddedSolrServer(this, null) {
- @Override
- public void close() throws IOException {
- // do nothing - we close the container ourselves
- }
- };
+ client = new EmbeddedSolrServer(this, null);
// enable local metrics unless specifically set otherwise
initArgs.putIfAbsent(MetricsHistoryHandler.ENABLE_NODES_PROP, true);
initArgs.putIfAbsent(MetricsHistoryHandler.ENABLE_REPLICAS_PROP, true);
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
index 1bce4222385..41c093f1f14 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AbstractAtomicUpdatesMultivalueTestBase.java
@@ -58,13 +58,7 @@ public abstract class AbstractAtomicUpdatesMultivalueTestBase extends EmbeddedSo
@Override
public synchronized EmbeddedSolrServer getSolrClient() {
- return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME, getRequestWriterSupplier()) {
-
- @Override
- public void close() {
- // do not close core container
- }
- };
+ return new EmbeddedSolrServer(h.getCoreContainer(), DEFAULT_CORE_NAME, getRequestWriterSupplier());
}
private static void assertQR(final String fieldName, final String queryValue, final int numFound) {
diff --git a/solr/solr-ref-guide/src/solr-upgrade-notes.adoc b/solr/solr-ref-guide/src/solr-upgrade-notes.adoc
index 13899cb2f94..c4f29b5243d 100644
--- a/solr/solr-ref-guide/src/solr-upgrade-notes.adoc
+++ b/solr/solr-ref-guide/src/solr-upgrade-notes.adoc
@@ -38,6 +38,17 @@ Detailed steps for upgrading a Solr cluster are in the section <