LUCENE-5871: test bugs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1618063 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-08-14 21:44:39 +00:00
parent b49aa49762
commit ce7e43e7e3
2 changed files with 9 additions and 4 deletions

View File

@ -253,7 +253,7 @@ public class TestIndexWriterThreadsToSegments extends LuceneTestCase {
startingGun.await();
Document doc = new Document();
doc.add(new TextField("field", "here is some text that is a bit longer than normal trivial text", Field.Store.NO));
while (true) {
for(int j=0;j<1000;j++) {
w.addDocument(doc);
}
} catch (AlreadyClosedException ace) {
@ -269,10 +269,15 @@ public class TestIndexWriterThreadsToSegments extends LuceneTestCase {
startingGun.countDown();
Thread.sleep(100);
w.close();
try {
w.close();
} catch (IllegalStateException ise) {
// OK but not required
}
for(Thread t : threads) {
t.join();
}
w.close();
dir.close();
}

View File

@ -351,12 +351,12 @@ public class RandomIndexWriter implements Closeable {
*/
@Override
public void close() throws IOException {
if (!w.isClosed()) {
if (w.isClosed() == false) {
LuceneTestCase.maybeChangeLiveIndexWriterConfig(r, w.getConfig());
}
// if someone isn't using getReader() API, we want to be sure to
// forceMerge since presumably they might open a reader on the dir.
if (getReaderCalled == false && r.nextInt(8) == 2) {
if (getReaderCalled == false && r.nextInt(8) == 2 && w.isClosed() == false) {
doRandomForceMerge();
if (w.getConfig().getCommitOnClose() == false) {
// index may have changed, must commit the changes, or otherwise they are discarded by the call to close()