Skip to content

Apache Lucene open-source search software

SOLR-465: fix SolrIndexWriter constructors to take DirectoryFactory

Yonik Seeley97db6150fab7
diff --git a/src/java/org/apache/solr/update/SolrIndexWriter.java b/src/java/org/apache/solr/update/SolrIndexWriter.java
index 50472440af6..1e8287f1324 100644
--- a/src/java/org/apache/solr/update/SolrIndexWriter.java
+++ b/src/java/org/apache/solr/update/SolrIndexWriter.java
@@ -120,6 +120,7 @@ public class SolrIndexWriter extends IndexWriter {
* @deprecated use getDirectory(String path, DirectoryFactory directoryFactory, SolrIndexConfig config)
*/
public static Directory getDirectory(String path, SolrIndexConfig config) throws IOException {
+ log.warn("SolrIndexWriter is using LEGACY_DIR_FACTORY which means deprecated code is likely in use and SolrIndexWriter is ignoring any custom DirectoryFactory.");
return getDirectory(path, LEGACY_DIR_FACTORY, config);
}
@@ -155,8 +156,8 @@ public class SolrIndexWriter extends IndexWriter {
init(name, schema, config);
}
- public SolrIndexWriter(String name, String path, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy) throws IOException {
- super(getDirectory(path, config), schema.getAnalyzer(), create, delPolicy, new MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH));
+ public SolrIndexWriter(String name, String path, DirectoryFactory dirFactory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy) throws IOException {
+ super(getDirectory(path, dirFactory, config), schema.getAnalyzer(), create, delPolicy, new MaxFieldLength(IndexWriter.DEFAULT_MAX_FIELD_LENGTH));
init(name, schema, config);
}
diff --git a/src/java/org/apache/solr/update/UpdateHandler.java b/src/java/org/apache/solr/update/UpdateHandler.java
index 15c9ee3dec7..733f115b0f4 100644
--- a/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/src/java/org/apache/solr/update/UpdateHandler.java
@@ -120,7 +120,7 @@ public abstract class UpdateHandler implements SolrInfoMBean {
}
protected SolrIndexWriter createMainIndexWriter(String name, boolean removeAllExisting) throws IOException {
- return new SolrIndexWriter(name,core.getNewIndexDir(), removeAllExisting, schema, core.getSolrConfig().mainIndexConfig, core.getDeletionPolicy());
+ return new SolrIndexWriter(name,core.getNewIndexDir(), core.getDirectoryFactory(), removeAllExisting, schema, core.getSolrConfig().mainIndexConfig, core.getDeletionPolicy());
}
protected final Term idTerm(String readableId) {