This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch jira/solr16547
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/jira/solr16547 by this push:
new 02c51f349b9 more refactoring
02c51f349b9 is described below
commit 02c51f349b902b32822e3f7adfa7ad6086fddaf1
Author: Noble Paul <[email protected]>
AuthorDate: Thu Nov 17 18:15:51 2022 +1100
more refactoring
---
.../java/org/apache/solr/core/ResponseWriters.java | 22 +++++++++++++++-------
.../src/java/org/apache/solr/core/SolrCore.java | 16 ++++------------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/ResponseWriters.java
b/solr/core/src/java/org/apache/solr/core/ResponseWriters.java
index 2579625334b..d4405d49dfc 100644
--- a/solr/core/src/java/org/apache/solr/core/ResponseWriters.java
+++ b/solr/core/src/java/org/apache/solr/core/ResponseWriters.java
@@ -127,13 +127,21 @@ public class ResponseWriters {
void write(OutputStream os) throws IOException;
}
+ /**
+ * Configure the query response writers. There will always be a default
writer; additional writers
+ * may also be configured.
+ */
+ public static PluginBag<QueryResponseWriter> create(SolrCore core) {
+ PluginBag<QueryResponseWriter> responseWriters = new PluginBag<>(
+ QueryResponseWriter.class,
+ core,
+ false,
+ DEFAULT_RESPONSE_WRITER_HOLDERS,
+ info);
- public static PluginBag<QueryResponseWriter> constructBag(SolrCore core) {
- return new PluginBag<>(
- QueryResponseWriter.class,
- core,
- false,
- ResponseWriters.DEFAULT_RESPONSE_WRITER_HOLDERS,
- ResponseWriters.info);
+ responseWriters.init(null, core);
+ // configure the default response writer; this one should never be null
+ if (responseWriters.getDefault() == null)
responseWriters.setDefault("standard");
+ return responseWriters;
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java
b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index d88143e06d9..656a0f74e78 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1107,7 +1107,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
this.codec = initCodec(solrConfig, this.schema);
initIndex(prev != null, reload);
- initWriters();
+ responseWriters = ResponseWriters.create(this);
qParserPlugins.init(QParserPlugin.standardPlugins, this);
valueSourceParsers.init(ValueSourceParser.standardValueSourceParsers,
this);
transformerFactories.init(TransformerFactory.defaultFactories, this);
@@ -1755,7 +1755,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
}
if (reqHandlers != null) reqHandlers.close();
- responseWriters.close();
+ if (responseWriters != null) responseWriters.close();
searchComponents.close();
qParserPlugins.close();
valueSourceParsers.close();
@@ -2975,22 +2975,14 @@ public class SolrCore implements SolrInfoBean,
Closeable {
return responseWriters;
}
- private final PluginBag<QueryResponseWriter> responseWriters =
ResponseWriters.constructBag(this);
+ private final PluginBag<QueryResponseWriter> responseWriters ;
public void fetchLatestSchema() {
IndexSchema schema = configSet.getIndexSchema(true);
setLatestSchema(schema);
}
- /**
- * Configure the query response writers. There will always be a default
writer; additional writers
- * may also be configured.
- */
- private void initWriters() {
- responseWriters.init(null, this);
- // configure the default response writer; this one should never be null
- if (responseWriters.getDefault() == null)
responseWriters.setDefault("standard");
- }
+
/** Finds a writer by name, or returns the default writer if not found. */
public final QueryResponseWriter getQueryResponseWriter(String writerName) {