Apache Lucene open-source search software
Add support to also reload HashFunctions when Solr boots (otherwise codecs using new hash functions may fail to load). We may need a better "automatic" reloading with one method call, that reloads all NamedSPILoaders. I will think about it and open issue. Solr could then only call NamedSPILoader.reloadAll(), so all instantiated ones get reloaded automatically. Currently its to risky to add new SPIs without Solr support (because it cannot be tested).
Uwe Schindler2c381580320c
diff --git a/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java b/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.javaindex fdb7b013345..1d940ad3734 100644--- a/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java+++ b/lucene/core/src/java/org/apache/lucene/util/hash/HashFunction.java@@ -62,7 +62,21 @@ public abstract class HashFunction implements NamedSPILoader.NamedSPI {return loader.availableServices();}-+ /**+ * Reloads the hash function list from the given {@link ClassLoader}.+ * Changes to the function list are visible after the method ends, all+ * iterators ({@link #availableHashFunctionNames()},...) stay consistent.+ *+ * <p><b>NOTE:</b> Only new functions are added, existing ones are+ * never removed or replaced.+ *+ * <p><em>This method is expensive and should only be called for discovery+ * of new functions on the given classpath/classloader!</em>+ */+ public static void reloadHashFunctions(ClassLoader classloader) {+ loader.reload(classloader);+ }+@Overridepublic String toString() {return name;diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.javaindex 8180d411f97..d7825b8fd39 100644--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java@@ -36,6 +36,7 @@ import org.apache.lucene.analysis.util.TokenFilterFactory;import org.apache.lucene.analysis.util.TokenizerFactory;import org.apache.lucene.codecs.Codec;import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.util.hash.HashFunction;import org.apache.lucene.analysis.util.WordlistLoader;import org.apache.solr.common.ResourceLoader;import org.apache.solr.handler.admin.CoreAdminHandler;@@ -175,6 +176,8 @@ public class SolrResourceLoader implements ResourceLoader* this ResourceLoader.*/void reloadLuceneSPI() {+ // Hash functions:+ HashFunction.reloadHashFunctions(this.classLoader);// Codecs:PostingsFormat.reloadPostingsFormats(this.classLoader);Codec.reloadCodecs(this.classLoader);