LUCENE-7414: TestUtil.checkIterator can make tests very slow

This commit is contained in:
Robert Muir 2016-08-16 16:12:55 -04:00
parent 7072458ea4
commit 18373e1129
1 changed files with 8 additions and 5 deletions

View File

@ -177,11 +177,14 @@ public final class TestUtil {
assert hasNext; assert hasNext;
T v = iterator.next(); T v = iterator.next();
assert allowNull || v != null; assert allowNull || v != null;
try { // for the first element, check that remove is not supported
iterator.remove(); if (i == 0) {
throw new AssertionError("broken iterator (supports remove): " + iterator); try {
} catch (UnsupportedOperationException expected) { iterator.remove();
// ok throw new AssertionError("broken iterator (supports remove): " + iterator);
} catch (UnsupportedOperationException expected) {
// ok
}
} }
} }
assert !iterator.hasNext(); assert !iterator.hasNext();