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.java index 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. + * + *
NOTE: Only new functions are added, existing ones are + * never removed or replaced. + * + *
This method is expensive and should only be called for discovery + * of new functions on the given classpath/classloader! + */ + public static void reloadHashFunctions(ClassLoader classloader) { + loader.reload(classloader); + } + @Override public 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.java index 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);