mirror of https://github.com/apache/lucene.git
woops, revert
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c2421c0929
commit
d01f0838e4
|
@ -468,22 +468,12 @@ def testChangesText(dir, version, project):
|
|||
checkChangesContent(open(fullPath, encoding='UTF-8').read(), version, fullPath, project, False)
|
||||
|
||||
reChangesSectionHREF = re.compile('<a id="(.*?)".*?>(.*?)</a>', re.IGNORECASE)
|
||||
reUnderbarNotDashHTML = re.compile(r'<li>(\s*(LUCENE|SOLR)_\d\d\d\d+)')
|
||||
reUnderbarNotDashTXT = re.compile(r'\s+((LUCENE|SOLR)_\d\d\d\d+)', re.MULTILINE)
|
||||
|
||||
def checkChangesContent(s, version, name, project, isHTML):
|
||||
|
||||
if isHTML and s.find('Release %s' % version) == -1:
|
||||
raise RuntimeError('did not see "Release %s" in %s' % (version, name))
|
||||
|
||||
if isHTML:
|
||||
r = reUnderbarNotDashHTML
|
||||
else:
|
||||
r = reUnderbarNotDashTXT
|
||||
|
||||
m = r.search(s)
|
||||
if m is not None:
|
||||
raise RuntimeError('incorrect issue (_ instead of -) in %s: %s' % (name, m.group(1)))
|
||||
|
||||
if s.lower().find('not yet released') != -1:
|
||||
raise RuntimeError('saw "not yet released" in %s' % name)
|
||||
|
||||
|
|
|
@ -148,9 +148,7 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
// remember which readers are shared between the old and the re-opened
|
||||
// DirectoryReader - we have to incRef those readers
|
||||
boolean[] readerShared = new boolean[infos.size()];
|
||||
|
||||
System.out.println("CYCLE infos=" + infos.size());
|
||||
|
||||
|
||||
for (int i = infos.size() - 1; i>=0; i--) {
|
||||
// find SegmentReader for this segment
|
||||
Integer oldReaderIndex = segmentReaders.get(infos.info(i).info.name);
|
||||
|
@ -161,7 +159,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
// there is an old reader for this segment - we'll try to reopen it
|
||||
newReaders[i] = (SegmentReader) oldReaders.get(oldReaderIndex.intValue());
|
||||
}
|
||||
System.out.println(" i=" + i + " newReaders[i]=" + newReaders[i]);
|
||||
|
||||
boolean success = false;
|
||||
Throwable prior = null;
|
||||
|
@ -174,7 +171,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
readerShared[i] = false;
|
||||
newReaders[i] = newReader;
|
||||
} else {
|
||||
System.out.println(" now in else");
|
||||
if (newReaders[i].getSegmentInfo().getDelGen() == infos.info(i).getDelGen()
|
||||
&& newReaders[i].getSegmentInfo().getFieldInfosGen() == infos.info(i).getFieldInfosGen()) {
|
||||
// No change; this reader will be shared between
|
||||
|
@ -183,7 +179,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
readerShared[i] = true;
|
||||
newReaders[i].incRef();
|
||||
} else {
|
||||
System.out.println(" has changes");
|
||||
// there are changes to the reader, either liveDocs or DV updates
|
||||
readerShared[i] = false;
|
||||
// Steal the ref returned by SegmentReader ctor:
|
||||
|
@ -196,7 +191,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
// both DV and liveDocs have changed
|
||||
newReaders[i] = new SegmentReader(infos.info(i), newReaders[i]);
|
||||
}
|
||||
System.out.println(" done open");
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
|
@ -206,7 +200,6 @@ final class StandardDirectoryReader extends DirectoryReader {
|
|||
if (!success) {
|
||||
for (i++; i < infos.size(); i++) {
|
||||
if (newReaders[i] != null) {
|
||||
System.out.println(" decRef i=" + i);
|
||||
try {
|
||||
if (!readerShared[i]) {
|
||||
// this is a new subReader that is not used by the old one,
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
|
@ -38,8 +37,6 @@ import org.apache.lucene.search.IndexSearcher;
|
|||
import org.apache.lucene.search.ScoreDoc;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper.FakeIOException;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
|
@ -621,73 +618,4 @@ public class TestDirectoryReaderReopen extends LuceneTestCase {
|
|||
r2.close();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
public void testOverDecRefDuringReopen() throws Exception {
|
||||
MockDirectoryWrapper dir = newMockDirectory();
|
||||
|
||||
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
iwc.setCodec(Codec.forName("Lucene46"));
|
||||
IndexWriter w = new IndexWriter(dir, iwc);
|
||||
Document doc = new Document();
|
||||
doc.add(newStringField("id", "id", Field.Store.NO));
|
||||
w.addDocument(doc);
|
||||
doc = new Document();
|
||||
doc.add(newStringField("id", "id2", Field.Store.NO));
|
||||
w.addDocument(doc);
|
||||
w.commit();
|
||||
|
||||
// Open reader w/ one segment w/ 2 docs:
|
||||
DirectoryReader r = DirectoryReader.open(dir);
|
||||
|
||||
// Delete 1 doc from the segment:
|
||||
System.out.println("TEST: now delete");
|
||||
w.deleteDocuments(new Term("id", "id"));
|
||||
System.out.println("TEST: now commit");
|
||||
w.commit();
|
||||
|
||||
// Fail when reopen tries to open the live docs file:
|
||||
dir.failOn(new MockDirectoryWrapper.Failure() {
|
||||
|
||||
int failCount;
|
||||
|
||||
@Override
|
||||
public void eval(MockDirectoryWrapper dir) throws IOException {
|
||||
// Need to throw exc three times so the logic in
|
||||
// SegmentInfos.FindSegmentsFile "really believes" us:
|
||||
if (failCount >= 3) {
|
||||
return;
|
||||
}
|
||||
//System.out.println("failOn: ");
|
||||
//new Throwable().printStackTrace(System.out);
|
||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||
for (int i = 0; i < trace.length; i++) {
|
||||
if ("readLiveDocs".equals(trace[i].getMethodName())) {
|
||||
if (VERBOSE) {
|
||||
System.out.println("TEST: now fail; exc:");
|
||||
new Throwable().printStackTrace(System.out);
|
||||
}
|
||||
failCount++;
|
||||
throw new FakeIOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Now reopen:
|
||||
System.out.println("TEST: now reopen");
|
||||
try {
|
||||
IndexReader r2 = DirectoryReader.openIfChanged(r);
|
||||
System.out.println("got " + r2);
|
||||
fail("didn't hit exception");
|
||||
} catch (FakeIOException fio) {
|
||||
// expected
|
||||
}
|
||||
|
||||
IndexSearcher s = newSearcher(r);
|
||||
assertEquals(1, s.search(new TermQuery(new Term("id", "id")), 1).totalHits);
|
||||
|
||||
r.close();
|
||||
w.close();
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue