Skip to content

Apache Lucene open-source search software

Make IndexSearcher#getSlices final and clarify docs (#12718)

Luca Cavanna09da2291c501
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d8347d6c03c..c5904daf311 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -156,6 +156,8 @@ API Changes
* GITHUB#12646, GITHUB#12690: Move FST#addNode to FSTCompiler to avoid a circular dependency
between FST and FSTCompiler (Anh Dung Bui)
+* GITHUB#12718: Make IndexSearcher#getSlices final as it is not expected to be overridden (Luca Cavanna)
+
New Features
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
index ff53dbb0d81..50f20876e47 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
@@ -115,10 +115,10 @@ public class IndexSearcher {
protected final List<LeafReaderContext> leafContexts;
/**
- * used with executor - LeafSlice supplier where each slice holds a set of leafs executed within
+ * Used with executor - LeafSlice supplier where each slice holds a set of leafs executed within
* one thread. We are caching it instead of creating it eagerly to avoid calling a protected
- * method from constructor, which is a bad practice. This is {@code null} if no executor is
- * provided
+ * method from constructor, which is a bad practice. Always non-null, regardless of whether an
+ * executor is provided or not.
*/
private final Supplier<LeafSlice[]> leafSlicesSupplier;
@@ -425,11 +425,12 @@ public class IndexSearcher {
}
/**
- * Returns the leaf slices used for concurrent searching
+ * Returns the leaf slices used for concurrent searching. Override {@link #slices(List)} to
+ * customize how slices are created.
*
* @lucene.experimental
*/
- public LeafSlice[] getSlices() {
+ public final LeafSlice[] getSlices() {
return leafSlicesSupplier.get();
}