mirror of https://github.com/apache/lucene.git
LUCENE-3620: Add Shais patch to branch
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1211555 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f86a10e8f
commit
40a2e04fc0
|
@ -426,4 +426,14 @@ public class FilterIndexReader extends IndexReader {
|
|||
ensureOpen();
|
||||
return in.perDocValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexCommit getIndexCommit() throws IOException {
|
||||
return in.getIndexCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTermInfosIndexDivisor() {
|
||||
return in.getTermInfosIndexDivisor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ import org.apache.lucene.util.BytesRef;
|
|||
import org.apache.lucene.util.Bits;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TestFilterIndexReader extends LuceneTestCase {
|
||||
|
||||
|
@ -167,4 +170,28 @@ public class TestFilterIndexReader extends LuceneTestCase {
|
|||
directory.close();
|
||||
target.close();
|
||||
}
|
||||
|
||||
public void testOverrideMethods() throws Exception {
|
||||
HashSet<String> methodsThatShouldNotBeOverridden = new HashSet<String>();
|
||||
methodsThatShouldNotBeOverridden.add("doOpenIfChanged");
|
||||
methodsThatShouldNotBeOverridden.add("clone");
|
||||
boolean fail = false;
|
||||
for (Method m : FilterIndexReader.class.getMethods()) {
|
||||
int mods = m.getModifiers();
|
||||
if (Modifier.isStatic(mods) || Modifier.isFinal(mods)) {
|
||||
continue;
|
||||
}
|
||||
Class< ? > declaringClass = m.getDeclaringClass();
|
||||
String name = m.getName();
|
||||
if (declaringClass != FilterIndexReader.class && declaringClass != Object.class && !methodsThatShouldNotBeOverridden.contains(name)) {
|
||||
System.err.println("method is not overridden by FilterIndexReader: " + name);
|
||||
fail = true;
|
||||
} else if (declaringClass == FilterIndexReader.class && methodsThatShouldNotBeOverridden.contains(name)) {
|
||||
System.err.println("method should not be overridden by FilterIndexReader: " + name);
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
assertFalse("FilterIndexReader overrides (or not) some problematic methods; see log above", fail);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue