MDW's assertNoUnreferencedFilesOnClose should still run even if checkIndexOnClose is turned off

This commit is contained in:
Mike McCandless 2016-02-07 09:19:57 -05:00
parent 53597e8f8e
commit 8e8aa0869e
1 changed files with 58 additions and 57 deletions

View File

@ -722,20 +722,22 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
throw new RuntimeException("MockDirectoryWrapper: cannot close: there are still open locks: " + openLocks, cause);
}
if (getCheckIndexOnClose()) {
randomIOExceptionRate = 0.0;
randomIOExceptionRateOnOpen = 0.0;
if (DirectoryReader.indexExists(this)) {
if ((getCheckIndexOnClose() || assertNoUnreferencedFilesOnClose) && DirectoryReader.indexExists(this)) {
if (LuceneTestCase.VERBOSE) {
System.out.println("\nNOTE: MockDirectoryWrapper: now crush");
}
if (getCheckIndexOnClose()) {
crash(); // corrupt any unsynced-files
if (LuceneTestCase.VERBOSE) {
System.out.println("\nNOTE: MockDirectoryWrapper: now run CheckIndex");
}
TestUtil.checkIndex(this, getCrossCheckTermVectorsOnClose(), true);
}
// TODO: factor this out / share w/ TestIW.assertNoUnreferencedFiles
if (assertNoUnreferencedFilesOnClose) {
@ -797,7 +799,6 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
assert numDocs1 == numDocs2 : "numDocs changed after opening/closing IW: before=" + numDocs1 + " after=" + numDocs2;
}
}
}
success = true;
} finally {
if (success) {