mirror of https://github.com/apache/lucene.git
fix rare-ish test bug
This commit is contained in:
parent
7523ca1162
commit
859ad950cc
|
@ -28,6 +28,7 @@ import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.IndexOutput;
|
import org.apache.lucene.store.IndexOutput;
|
||||||
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
import org.apache.lucene.util.LineFileDocs;
|
import org.apache.lucene.util.LineFileDocs;
|
||||||
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
@ -86,6 +87,12 @@ public class TestAllFilesCheckIndexHeader extends LuceneTestCase {
|
||||||
private void checkOneFile(Directory dir, String victim) throws IOException {
|
private void checkOneFile(Directory dir, String victim) throws IOException {
|
||||||
try (BaseDirectoryWrapper dirCopy = newDirectory()) {
|
try (BaseDirectoryWrapper dirCopy = newDirectory()) {
|
||||||
dirCopy.setCheckIndexOnClose(false);
|
dirCopy.setCheckIndexOnClose(false);
|
||||||
|
|
||||||
|
if (dirCopy instanceof MockDirectoryWrapper) {
|
||||||
|
// The while(true) loop below, under rarish circumstances, can sometimes double write:
|
||||||
|
((MockDirectoryWrapper) dirCopy).setPreventDoubleWrite(false);
|
||||||
|
}
|
||||||
|
|
||||||
long victimLength = dir.fileLength(victim);
|
long victimLength = dir.fileLength(victim);
|
||||||
int wrongBytes = TestUtil.nextInt(random(), 1, (int) Math.min(100, victimLength));
|
int wrongBytes = TestUtil.nextInt(random(), 1, (int) Math.min(100, victimLength));
|
||||||
assert victimLength > 0;
|
assert victimLength > 0;
|
||||||
|
|
Loading…
Reference in New Issue