diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 65281b59160..7e803cf0a3a 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -135,6 +135,10 @@ API Changes
* LUCENE-7056: Geo3D classes are in different packages now. (David Smiley)
+* LUCENE-6952: These classes are now abstract: FilterCodecReader, FilterLeafReader,
+ FilterCollector, FilterDirectory. And some Filter* classes in
+ lucene-test-framework too. (David Smiley)
+
Optimizations
* LUCENE-6891: Use prefix coding when writing points in
diff --git a/lucene/core/src/java/org/apache/lucene/index/FilterCodecReader.java b/lucene/core/src/java/org/apache/lucene/index/FilterCodecReader.java
index 41f09843aed..c35dc6719c9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FilterCodecReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FilterCodecReader.java
@@ -32,7 +32,7 @@ import org.apache.lucene.util.Bits;
* uses as its basic source of data, possibly transforming the data along the
* way or providing additional functionality.
*/
-public class FilterCodecReader extends CodecReader {
+public abstract class FilterCodecReader extends CodecReader {
/**
* The underlying CodecReader instance.
*/
diff --git a/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java b/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
index 98365a6cf65..1d593c32a12 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FilterLeafReader.java
@@ -44,7 +44,7 @@ import org.apache.lucene.util.BytesRef;
* overridden as well if the {@link #getLiveDocs() live docs} are not changed
* either.
*/
-public class FilterLeafReader extends LeafReader {
+public abstract class FilterLeafReader extends LeafReader {
/** Get the wrapped instance by reader
as long as this reader is
* an instance of {@link FilterLeafReader}. */
@@ -57,7 +57,7 @@ public class FilterLeafReader extends LeafReader {
/** Base class for filtering {@link Fields}
* implementations. */
- public static class FilterFields extends Fields {
+ public abstract static class FilterFields extends Fields {
/** The underlying Fields instance. */
protected final Fields in;
@@ -93,7 +93,7 @@ public class FilterLeafReader extends LeafReader {
* these terms are going to be intersected with automata, you could consider
* overriding {@link #intersect} for better performance.
*/
- public static class FilterTerms extends Terms {
+ public abstract static class FilterTerms extends Terms {
/** The underlying Terms instance. */
protected final Terms in;
@@ -160,7 +160,7 @@ public class FilterLeafReader extends LeafReader {
}
/** Base class for filtering {@link TermsEnum} implementations. */
- public static class FilterTermsEnum extends TermsEnum {
+ public abstract static class FilterTermsEnum extends TermsEnum {
/** The underlying TermsEnum instance. */
protected final TermsEnum in;
@@ -223,7 +223,7 @@ public class FilterLeafReader extends LeafReader {
}
/** Base class for filtering {@link PostingsEnum} implementations. */
- public static class FilterPostingsEnum extends PostingsEnum {
+ public abstract static class FilterPostingsEnum extends PostingsEnum {
/** The underlying PostingsEnum instance. */
protected final PostingsEnum in;
diff --git a/lucene/core/src/java/org/apache/lucene/search/FilterCollector.java b/lucene/core/src/java/org/apache/lucene/search/FilterCollector.java
index d290330f5d6..d4ec9149267 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FilterCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FilterCollector.java
@@ -26,7 +26,7 @@ import org.apache.lucene.index.LeafReaderContext;
*
* @lucene.experimental
*/
-public class FilterCollector implements Collector {
+public abstract class FilterCollector implements Collector {
protected final Collector in;
diff --git a/lucene/core/src/java/org/apache/lucene/search/FilterLeafCollector.java b/lucene/core/src/java/org/apache/lucene/search/FilterLeafCollector.java
index ab15babad0b..b55410c87c7 100644
--- a/lucene/core/src/java/org/apache/lucene/search/FilterLeafCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/FilterLeafCollector.java
@@ -24,7 +24,7 @@ import java.io.IOException;
*
* @lucene.experimental
*/
-public class FilterLeafCollector implements LeafCollector {
+public abstract class FilterLeafCollector implements LeafCollector {
protected final LeafCollector in;
diff --git a/lucene/core/src/java/org/apache/lucene/store/FilterDirectory.java b/lucene/core/src/java/org/apache/lucene/store/FilterDirectory.java
index 5df571358ae..8148b5ac3a3 100644
--- a/lucene/core/src/java/org/apache/lucene/store/FilterDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/FilterDirectory.java
@@ -29,7 +29,7 @@ import java.util.Collection;
* {@link Directory} or {@link BaseDirectory} rather than try to reuse
* functionality of existing {@link Directory}s by extending this class.
* @lucene.internal */
-public class FilterDirectory extends Directory {
+public abstract class FilterDirectory extends Directory {
/** Get the wrapped instance by dir
as long as this reader is
* an instance of {@link FilterDirectory}. */
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java b/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java
index 82fb3bce2f6..cad47a4e126 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestFilterLeafReader.java
@@ -196,7 +196,7 @@ public class TestFilterLeafReader extends LuceneTestCase {
w.addDocument(new Document());
DirectoryReader dr = w.getReader();
LeafReader r = dr.leaves().get(0).reader();
- FilterLeafReader r2 = new FilterLeafReader(r);
+ FilterLeafReader r2 = new FilterLeafReader(r) {};
assertEquals(r, r2.getDelegate());
assertEquals(r, FilterLeafReader.unwrap(r2));
w.close();
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestFilterDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestFilterDirectory.java
index 7fe9bc2be0d..6224140e3ca 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestFilterDirectory.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestFilterDirectory.java
@@ -29,7 +29,7 @@ public class TestFilterDirectory extends BaseDirectoryTestCase {
@Override
protected Directory getDirectory(Path path) throws IOException {
- return new FilterDirectory(new RAMDirectory());
+ return new FilterDirectory(new RAMDirectory()) {};
}
@Test
@@ -48,7 +48,7 @@ public class TestFilterDirectory extends BaseDirectoryTestCase {
public void testUnwrap() throws IOException {
Directory dir = FSDirectory.open(createTempDir());
- FilterDirectory dir2 = new FilterDirectory(dir);
+ FilterDirectory dir2 = new FilterDirectory(dir) {};
assertEquals(dir, dir2.getDelegate());
assertEquals(dir, FilterDirectory.unwrap(dir2));
dir2.close();
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java b/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
index bcee1b6c4e1..b40ac2685d5 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/MockRandomMergePolicy.java
@@ -159,7 +159,7 @@ public class MockRandomMergePolicy extends MergePolicy {
if (LuceneTestCase.VERBOSE) {
System.out.println("NOTE: MockRandomMergePolicy now swaps in a SlowCodecReaderWrapper for merging reader=" + readers.get(i));
}
- readers.set(i, SlowCodecReaderWrapper.wrap(new FilterLeafReader(readers.get(i))));
+ readers.set(i, SlowCodecReaderWrapper.wrap(new FilterLeafReader(readers.get(i)) {}));
} else if (thingToDo == 1) {
// renumber fields
// NOTE: currently this only "blocks" bulk merges just by
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java
index 0c95af0ee63..ccc6e7abc9e 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java
@@ -31,7 +31,7 @@ import java.util.Objects;
* source of data, possibly transforming the data along the
* way or providing additional functionality.
*/
-public class FilterFileChannel extends FileChannel {
+public abstract class FilterFileChannel extends FileChannel {
/**
* The underlying {@code FileChannel} instance.
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileStore.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileStore.java
index dc90799d6ec..423b32d75ba 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileStore.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileStore.java
@@ -28,7 +28,7 @@ import java.util.Objects;
* source of data, possibly transforming the data along the
* way or providing additional functionality.
*/
-public class FilterFileStore extends FileStore {
+public abstract class FilterFileStore extends FileStore {
/**
* The underlying {@code FileStore} instance.
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystem.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystem.java
index d79ed35e7f5..e24506d7cd5 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystem.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystem.java
@@ -131,7 +131,7 @@ public class FilterFileSystem extends FileSystem {
@Override
public FileStore next() {
- return new FilterFileStore(iterator.next(), parent.getScheme());
+ return new FilterFileStore(iterator.next(), parent.getScheme()) {};
}
@Override
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java
index c9c016551c8..8a7ff754e01 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java
@@ -48,7 +48,7 @@ import java.util.concurrent.ExecutorService;
* source of data, possibly transforming the data along the
* way or providing additional functionality.
*/
-public class FilterFileSystemProvider extends FileSystemProvider {
+public abstract class FilterFileSystemProvider extends FileSystemProvider {
/**
* The underlying {@code FileSystemProvider}.
diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterOutputStream2.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterOutputStream2.java
index dbf7a95bb71..5413c87dd71 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterOutputStream2.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterOutputStream2.java
@@ -34,7 +34,7 @@ import java.util.Objects;
* that just overrides {@code close} will not force bytes to be
* written one-at-a-time.
*/
-public class FilterOutputStream2 extends OutputStream {
+public abstract class FilterOutputStream2 extends OutputStream {
/**
* The underlying {@code OutputStream} instance.