LUCENE-3464: add asserts

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1178627 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-10-03 23:09:43 +00:00
parent ae43014041
commit edb79b1f39
1 changed files with 12 additions and 4 deletions

View File

@ -571,7 +571,9 @@ public abstract class IndexReader implements Cloneable,Closeable {
* IndexReader instance which you must eventually close
*/
public static IndexReader openIfChanged(IndexReader oldReader) throws IOException {
return oldReader.doOpenIfChanged();
final IndexReader newReader = oldReader.doOpenIfChanged();
assert newReader != oldReader;
return newReader;
}
/**
@ -583,7 +585,9 @@ public abstract class IndexReader implements Cloneable,Closeable {
* @see #openIfChanged(IndexReader)
*/
public static IndexReader openIfChanged(IndexReader oldReader, boolean readOnly) throws IOException {
return oldReader.doOpenIfChanged(readOnly);
final IndexReader newReader = oldReader.doOpenIfChanged(readOnly);
assert newReader != oldReader;
return newReader;
}
/**
@ -596,7 +600,9 @@ public abstract class IndexReader implements Cloneable,Closeable {
*/
// TODO: should you be able to specify readOnly?
public static IndexReader openIfChanged(IndexReader oldReader, IndexCommit commit) throws IOException {
return oldReader.doOpenIfChanged(commit);
final IndexReader newReader = oldReader.doOpenIfChanged(commit);
assert newReader != oldReader;
return newReader;
}
/**
@ -661,7 +667,9 @@ public abstract class IndexReader implements Cloneable,Closeable {
* @lucene.experimental
*/
public static IndexReader openIfChanged(IndexReader oldReader, IndexWriter writer, boolean applyAllDeletes) throws IOException {
return oldReader.doOpenIfChanged(writer, applyAllDeletes);
final IndexReader newReader = oldReader.doOpenIfChanged(writer, applyAllDeletes);
assert newReader != oldReader;
return newReader;
}
protected IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {